四角形の中心座標の算出(4点群指定)
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_cg_calc_rectangle_4npoint( DPNT_T_PTR pntsAB, int numAB, DPNT_T_PTR pntsBC, int numBC, DPNT_T_PTR pntsCD, int numCD, DPNT_T_PTR pntsDA, int numDA, f_line_detection_mode lsm_mode, int lsm_param, ref double long1, ref double short1, ref double long2, ref double short2, ref DPNT_T center ) |
Visual Basic |
---|
Public Shared Function fnFIE_cg_calc_rectangle_4npoint ( pntsAB As DPNT_T_PTR, numAB As Integer, pntsBC As DPNT_T_PTR, numBC As Integer, pntsCD As DPNT_T_PTR, numCD As Integer, pntsDA As DPNT_T_PTR, numDA As Integer, lsm_mode As f_line_detection_mode, lsm_param As Integer, ByRef long1 As Double, ByRef short1 As Double, ByRef long2 As Double, ByRef short2 As Double, ByRef center As DPNT_T ) As Integer |
Parameters
- pntsAB
- Type: fvalgcli..::..DPNT_T_PTR
辺ABを作る座標点群。 numAB 個の点が必要
- numAB
- Type: System..::..Int32
点群 pntsAB に入っている点の数(2〜1000)
- pntsBC
- Type: fvalgcli..::..DPNT_T_PTR
辺BCを作る座標点群。 numBC 個の点が必要
- numBC
- Type: System..::..Int32
点群 pntsBC に入っている点の数(2〜1000)
- pntsCD
- Type: fvalgcli..::..DPNT_T_PTR
辺CDを作る座標点群。 numCD 個の点が必要
- numCD
- Type: System..::..Int32
点群 pntsCD に入っている点の数(2〜1000)
- pntsDA
- Type: fvalgcli..::..DPNT_T_PTR
辺DAを作る座標点群。 numDA 個の点が必要
- numDA
- Type: System..::..Int32
点群 pntsDA に入っている点の数(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
直線生成のパラメータ
- long1
- Type: System..::..Double%
長辺1の長さ
- short1
- Type: System..::..Double%
短辺1の長さ
- long2
- Type: System..::..Double%
長辺2の長さ
- short2
- Type: System..::..Double%
短辺2の長さ
- center
- Type: fvalgcli..::..DPNT_T%
中心点座標
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 |
---|---|
// $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_rectangle_4npoint() { int status = (int)f_err.F_ERR_NONE; DPNT_T_PTR pnts1 = DPNT_T_PTR.Zero; DPNT_T_PTR pnts2 = DPNT_T_PTR.Zero; DPNT_T_PTR pnts3 = DPNT_T_PTR.Zero; DPNT_T_PTR pnts4 = DPNT_T_PTR.Zero; DPNT_T center = new DPNT_T(); double long_len1 = new double(); double long_len2 = new double(); double short_len1 = new double(); double short_len2 = new double(); int num = 25; f_line_detection_mode lsm_mode = f_line_detection_mode.F_LINE_DIRECT_NORMAL; int lsm_param = 0; DPNT_T ans_center = DPNT_T.init(200, 200); try { pnts1 = DPNT_T_PTR.alloc(num); pnts2 = DPNT_T_PTR.alloc(num); pnts3 = DPNT_T_PTR.alloc(num); pnts4 = DPNT_T_PTR.alloc(num); for (int i = 0; i < num; i++) { // X=200-Y, y=0,8......192 pnts1[i] = DPNT_T.init(200 - 8 * i, 8 * i); //X=Y+200, y=0,8......192 pnts2[i] = DPNT_T.init(8 * i + 200, 8 * i); //X+Y=600, y=200,208......392 pnts3[i] = DPNT_T.init(600 - 200 - 8 * i, 200 + 8 * i); //X=Y-200, y=200,208......392 pnts4[i] = DPNT_T.init(200 + 8 * i - 200, 200 + 8 * i); } status = api.fnFIE_cg_calc_rectangle_4npoint(pnts1, num, pnts2, num, pnts3, num, pnts4, num, lsm_mode, lsm_param, ref long_len1, ref short_len1, ref long_len2, ref short_len2, ref center); Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status); // 結果を出力する. ConsoleOut.WriteFunctionName(":\n"); Console.WriteLine("long_len1 = {0}", long_len1); Console.WriteLine("short_len1 = {0}", short_len1); Console.WriteLine("long_len2 = {0}", long_len2); Console.WriteLine("short_len2 = {0}", short_len2); Console.WriteLine("center.x = {0}", center.x); Console.WriteLine("center.y = {0}", center.y); Console.Write(" ..."); ConsoleOut.IsTrue(center.x == ans_center.x && center.y == ans_center.y); } finally { pnts1.Dispose(); pnts2.Dispose(); pnts3.Dispose(); pnts4.Dispose(); } } } } |
Visual Basic | Copy |
---|---|
' $Revision: 1.1 $ Imports System.Collections.Generic Imports System.Text Imports fvalgcli Public Partial Class FIE <FvPluginExecute> _ Public Sub fnFIE_cg_calc_rectangle_4npoint() Dim status As Integer = CInt(f_err.F_ERR_NONE) Dim pnts1 As DPNT_T_PTR = DPNT_T_PTR.Zero Dim pnts2 As DPNT_T_PTR = DPNT_T_PTR.Zero Dim pnts3 As DPNT_T_PTR = DPNT_T_PTR.Zero Dim pnts4 As DPNT_T_PTR = DPNT_T_PTR.Zero Dim center As New DPNT_T() Dim long_len1 As New Double() Dim long_len2 As New Double() Dim short_len1 As New Double() Dim short_len2 As New Double() Dim num As Integer = 25 Dim lsm_mode As f_line_detection_mode = f_line_detection_mode.F_LINE_DIRECT_NORMAL Dim lsm_param As Integer = 0 Dim ans_center As DPNT_T = DPNT_T.init(200, 200) Try pnts1 = DPNT_T_PTR.alloc(num) pnts2 = DPNT_T_PTR.alloc(num) pnts3 = DPNT_T_PTR.alloc(num) pnts4 = DPNT_T_PTR.alloc(num) For i As Integer = 0 To num - 1 ' X=200-Y, y=0,8......192 pnts1(i) = DPNT_T.init(200 - 8 * i, 8 * i) 'X=Y+200, y=0,8......192 pnts2(i) = DPNT_T.init(8 * i + 200, 8 * i) 'X+Y=600, y=200,208......392 pnts3(i) = DPNT_T.init(600 - 200 - 8 * i, 200 + 8 * i) 'X=Y-200, y=200,208......392 pnts4(i) = DPNT_T.init(200 + 8 * i - 200, 200 + 8 * i) Next status = api.fnFIE_cg_calc_rectangle_4npoint(pnts1, num, pnts2, num, pnts3, num, _ pnts4, num, lsm_mode, lsm_param, long_len1, short_len1, _ long_len2, short_len2, center) Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err)) ' 結果を出力する. ConsoleOut.WriteFunctionName(":" & vbLf) Console.WriteLine("long_len1 = {0}", long_len1) Console.WriteLine("short_len1 = {0}", short_len1) Console.WriteLine("long_len2 = {0}", long_len2) Console.WriteLine("short_len2 = {0}", short_len2) Console.WriteLine("center.x = {0}", center.x) Console.WriteLine("center.y = {0}", center.y) Console.Write(" ...") ConsoleOut.IsTrue(center.x = ans_center.x AndAlso center.y = ans_center.y) Finally pnts1.Dispose() pnts2.Dispose() pnts3.Dispose() pnts4.Dispose() End Try End Sub End Class |