点群から直線を算出(直線近似)

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

Syntax

C#
public static int fnFIE_cg_calc_line_npoint(
	DPNT_T_PTR pnts,
	int num,
	f_line_detection_mode lsm_mode,
	int lsm_param,
	ref DLINE_T line,
	ref double angle
)
Visual Basic
Public Shared Function fnFIE_cg_calc_line_npoint ( 
	pnts As DPNT_T_PTR,
	num As Integer,
	lsm_mode As f_line_detection_mode,
	lsm_param As Integer,
	ByRef line As DLINE_T,
	ByRef angle As Double
) As Integer

Parameters

pnts
Type: fvalgcli..::..DPNT_T_PTR
直線を生成する座標点群G1。 num 個の点が必要
num
Type: System..::..Int32
点群に入っている点の数(2〜1000)
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
直線生成のパラメータ
line
Type: fvalgcli..::..DLINE_T%
求められた直線L1
angle
Type: System..::..Double%
求められた直線の傾き(単位:ラジアン [ -π/2〜 π/2] )

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_line_npoint()
        {
            int status = (int)f_err.F_ERR_NONE;

            DPNT_T_PTR pnt1 = DPNT_T_PTR.Zero;
            DLINE_T line = new DLINE_T();
            double angle = 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_angle = 45;

            try
            {
                pnt1 = DPNT_T_PTR.alloc(num);

                for (int i = 0; i < num; i++)
                {
                    pnt1[i] = DPNT_T.init(40 * i, 40 * i);
                }

                status = api.fnFIE_cg_calc_line_npoint(pnt1, num, lsm_mode, lsm_param, ref line, ref angle);

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

                // 結果を出力する.
                ConsoleOut.WriteFunctionName(":\n");
                Console.WriteLine("line.a {0}", line.a);
                Console.WriteLine("line.b {0}", line.b);
                Console.WriteLine("line.c {0}", line.c);
                Console.WriteLine("angle {0}", angle * 180 / Math.PI);
                Console.Write(" ...");
                ConsoleOut.IsTrue(angle * 180 / Math.PI == ans_angle);
            }
            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_line_npoint()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim pnt1 As DPNT_T_PTR = DPNT_T_PTR.Zero
        Dim line As New DLINE_T()
        Dim angle 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_angle As Double = 45

        Try
            pnt1 = DPNT_T_PTR.alloc(num)

            For i As Integer = 0 To num - 1
                pnt1(i) = DPNT_T.init(40 * i, 40 * i)
            Next

            status = api.fnFIE_cg_calc_line_npoint(pnt1, num, lsm_mode, lsm_param, line, angle)

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

            ' 結果を出力する.
            ConsoleOut.WriteFunctionName(":" & vbLf)
            Console.WriteLine("line.a {0}", line.a)
            Console.WriteLine("line.b {0}", line.b)
            Console.WriteLine("line.c {0}", line.c)
            Console.WriteLine("angle {0}", angle * 180 / Math.PI)
            Console.Write(" ...")
            ConsoleOut.IsTrue(angle * 180 / Math.PI = ans_angle)
        Finally
            pnt1.Dispose()
        End Try
    End Sub
End Class

See Also