線分の射影変換
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_geotrans_perspective_lineseg( DSGMT_T src, ref DSGMT_T dst, FMATRIX_PTR mat ) |
Visual Basic |
---|
Public Shared Function fnFIE_geotrans_perspective_lineseg ( src As DSGMT_T, ByRef dst As DSGMT_T, mat As FMATRIX_PTR ) As Integer |
Parameters
- src
- Type: fvalgcli..::..DSGMT_T
入力線分
- dst
- Type: fvalgcli..::..DSGMT_T%
出力線分
- mat
- Type: fvalgcli..::..FMATRIX_PTR
同次変換行列(3x3の正方行列)
Return Value
Type: Int32以下のエラーコードを返します。
エラーコード:
f_err | 内容 |
---|---|
F_ERR_NONE | 正常終了 |
F_ERR_INVALID_PARAM | 不正なパラメータが渡された |
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 { /// <summary> /// 線分の射影変換. /// </summary> /// <remarks> /// 変換行列. /// |7 2 0| /// |3 6 0| /// |6 4 4} /// /// 線分. /// (200, 150) - (400, 500) /// /// 期待値. /// st.x: 9.4235033259423506e-01 /// st.y: 8.3148558758314861e-01 /// ed.x: 8.6285195277020887e-01 /// ed.y: 9.5367847411444140e-01 /// </remarks> [FvPluginExecute] public void fnFIE_geotrans_perspective_lineseg() { int status = (int)f_err.F_ERR_NONE; // 期待値. const double ans_st_x = 9.4235033259423506e-01; const double ans_st_y = 8.3148558758314861e-01; const double ans_ed_x = 8.6285195277020887e-01; const double ans_ed_y = 9.5367847411444140e-01; // 同次変換行列の初期化. FMATRIX_PTR mat = IntPtr.Zero; DSGMT_T src = new DSGMT_T(); // 入力線分. DSGMT_T dst = new DSGMT_T(); // 出力線分. try { mat = FMATRIX_PTR.alloc(3, 3); { mat[0, 0] = 7; mat[0, 1] = 2; mat[0, 2] = 0; mat[1, 0] = 3; mat[1, 1] = 6; mat[1, 2] = 0; mat[2, 0] = 6; mat[2, 1] = 4; mat[2, 2] = 4; }; // 入力線分の設定. src.st.x = 200; src.st.y = 150; src.ed.x = 400; src.ed.y = 500; // 処理の実行. status = api.fnFIE_geotrans_perspective_lineseg(src, ref dst, mat); // エラー判定. Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status); // 結果出力. ConsoleOut.WriteFunctionName(":\n"); Console.Write("\tdst: ({0:f3} , {1:f3}) - ({2:f3} , {3:f3}) ...", dst.st.x, dst.st.y, dst.ed.x, dst.ed.y); ConsoleOut.IsTrue( DblEqual(dst.st.x, ans_st_x) && DblEqual(dst.st.y, ans_st_y) && DblEqual(dst.ed.x, ans_ed_x) && DblEqual(dst.ed.y, ans_ed_y) ); } finally { // オブジェクトの開放. mat.Dispose(); } } } } |
Visual Basic | Copy |
---|---|
' $Revision: 1.1 $ Imports System.Collections.Generic Imports System.Text Imports fvalgcli Public Partial Class FIE ''' <summary> ''' 線分の射影変換. ''' </summary> ''' <remarks> ''' 変換行列. ''' |7 2 0| ''' |3 6 0| ''' |6 4 4} ''' ''' 線分. ''' (200, 150) - (400, 500) ''' ''' 期待値. ''' st.x: 9.4235033259423506e-01 ''' st.y: 8.3148558758314861e-01 ''' ed.x: 8.6285195277020887e-01 ''' ed.y: 9.5367847411444140e-01 ''' </remarks> <FvPluginExecute> _ Public Sub fnFIE_geotrans_perspective_lineseg() Dim status As Integer = CInt(f_err.F_ERR_NONE) ' 期待値. Const ans_st_x As Double = 0.942350332594235 Const ans_st_y As Double = 0.831485587583149 Const ans_ed_x As Double = 0.862851952770209 Const ans_ed_y As Double = 0.953678474114441 ' 同次変換行列の初期化. Dim mat As FMATRIX_PTR = IntPtr.Zero Dim src As New DSGMT_T() ' 入力線分. Dim dst As New DSGMT_T() ' 出力線分. Try mat = FMATRIX_PTR.alloc(3, 3) If True Then mat(0, 0) = 7 mat(0, 1) = 2 mat(0, 2) = 0 mat(1, 0) = 3 mat(1, 1) = 6 mat(1, 2) = 0 mat(2, 0) = 6 mat(2, 1) = 4 mat(2, 2) = 4 End If ' 入力線分の設定. src.st.x = 200 src.st.y = 150 src.ed.x = 400 src.ed.y = 500 ' 処理の実行. status = api.fnFIE_geotrans_perspective_lineseg(src, dst, mat) ' エラー判定. Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err)) ' 結果出力. ConsoleOut.WriteFunctionName(":" & vbLf) Console.Write(vbTab & "dst: ({0:f3} , {1:f3}) - ({2:f3} , {3:f3}) ...", dst.st.x, dst.st.y, dst.ed.x, dst.ed.y) ConsoleOut.IsTrue(DblEqual(dst.st.x, ans_st_x) AndAlso DblEqual(dst.st.y, ans_st_y) AndAlso DblEqual(dst.ed.x, ans_ed_x) AndAlso DblEqual(dst.ed.y, ans_ed_y)) Finally ' オブジェクトの開放. mat.Dispose() End Try End Sub End Class |