点群を通る直線と点までの距離と中点座標の算出(点群と1点指定)

Namespace: fvalgcli
Assembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)

Syntax

C#
public static int fnFIE_cg_calc_center_point_and_lineB(
	DPNT_T_PTR pnts,
	int num,
	DPNT_T pnt,
	f_line_detection_mode lsm_mode,
	int lsm_param,
	ref DPNT_T center,
	ref double dist
)
Visual Basic
Public Shared Function fnFIE_cg_calc_center_point_and_lineB ( 
	pnts As DPNT_T_PTR,
	num As Integer,
	pnt As DPNT_T,
	lsm_mode As f_line_detection_mode,
	lsm_param As Integer,
	ByRef center As DPNT_T,
	ByRef dist As Double
) As Integer

Parameters

pnts
Type: fvalgcli..::..DPNT_T_PTR
直線を生成する座標点群G1。 num 個の点が必要
num
Type: System..::..Int32
点群に入っている点の数(2〜1000)
pnt
Type: fvalgcli..::..DPNT_T
距離と中点を求めるための座標点
lsm_mode
Type: fvalgcli..::..f_line_detection_mode
直線生成のモード
  • F_LINE_DIRECT_NORMAL 通常直線検出モード
  • F_LINE_DIRECT_NUM 回数指定モード
  • F_LINE_DIRECT_DIST_A 距離指定モード1
  • F_LINE_DIRECT_DIST_B 距離指定モード2
lsm_param
Type: System..::..Int32
直線生成のパラメータ
center
Type: fvalgcli..::..DPNT_T%
直線L1と点P1との中点座標Pc
dist
Type: System..::..Double%
直線L1と点P1との距離d

Return Value

Type: Int32
以下のエラーコードを返します。

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_PARAM 不正なパラメータが渡された
F_ERR_CALC_IMPOSSIBLE 計算不能エラー
F_ERR_NOMEMORYメモリ不足
F_ERR_NO_LICENCEライセンスエラー、または未初期化エラー

Remarks

Examples

C# Copy imageCopy
//    $Revision: 1.1 $

using System;
using System.Collections.Generic;
using System.Text;
using fvalgcli;

namespace TC
{
    public partial class FIE
    {
        [FvPluginExecute]
        public void fnFIE_cg_calc_center_point_and_lineB()
        {
            int status = (int)f_err.F_ERR_NONE;

            DPNT_T_PTR pnt1 = DPNT_T_PTR.Zero;
            DPNT_T pnt2 = new DPNT_T();
            DPNT_T center = new DPNT_T();
            double dist = new double();
            int num = 20;
            f_line_detection_mode lsm_mode = f_line_detection_mode.F_LINE_DIRECT_NORMAL;
            int lsm_param = 0;

            const double ans_dist = 169.70562748477;

            try
            {
                pnt1 = DPNT_T_PTR.alloc(num);

                // 点列の座標を設定.
                for (int i = 0; i < num; i++)
                {
                    pnt1[i] = DPNT_T.init(50 * i + 50,50 * i);
                }

                pnt2.x = 10;
                pnt2.y = 200;

                status = api.fnFIE_cg_calc_center_point_and_lineB(pnt1, num, pnt2, lsm_mode, lsm_param, ref center, ref dist);

                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status);

                // 結果を出力する.
                ConsoleOut.WriteFunctionName(":\n");
                Console.WriteLine("center = ({0},{1}), dist = {2}", center.x, center.y, dist);
                Console.Write(" ...");
                ConsoleOut.IsTrue(DblEqual(dist, ans_dist));
            }
            finally
            {
                pnt1.Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

Public Partial Class FIE
    <FvPluginExecute> _
    Public Sub fnFIE_cg_calc_center_point_and_lineB()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim pnt1 As DPNT_T_PTR = DPNT_T_PTR.Zero
        Dim pnt2 As New DPNT_T()
        Dim center As New DPNT_T()
        Dim dist As New Double()
        Dim num As Integer = 20
        Dim lsm_mode As f_line_detection_mode = f_line_detection_mode.F_LINE_DIRECT_NORMAL
        Dim lsm_param As Integer = 0

        Const  ans_dist As Double = 169.70562748477

        Try
            pnt1 = DPNT_T_PTR.alloc(num)

            ' 点列の座標を設定.
            For i As Integer = 0 To num - 1
                pnt1(i) = DPNT_T.init(50 * i + 50, 50 * i)
            Next

            pnt2.x = 10
            pnt2.y = 200

            status = api.fnFIE_cg_calc_center_point_and_lineB(pnt1, num, pnt2, lsm_mode, lsm_param, center, _
                dist)

            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err))

            ' 結果を出力する.
            ConsoleOut.WriteFunctionName(":" & vbLf)
            Console.WriteLine("center = ({0},{1}), dist = {2}", center.x, center.y, dist)
            Console.Write(" ...")
            ConsoleOut.IsTrue(DblEqual(dist, ans_dist))
        Finally
            pnt1.Dispose()
        End Try
    End Sub
End Class

See Also