線分のアフィン変換
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_geotrans_affine_lineseg( DSGMT_T src, ref DSGMT_T dst, FMATRIX_PTR mat ) |
Visual Basic |
---|
Public Shared Function fnFIE_geotrans_affine_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> /// 入力線分(200, 150)-(400, 500)を、(100, 200)を中心として45度回転させる. /// 期待値 /// st.x: 2.0606601717798213e+02 /// st.y: 2.3535533905932735e+02 /// ed.x: 1.0000000000000003e+02 /// ed.y: 6.2426406871192842e+02 /// </remarks> [FvPluginExecute] public void fnFIE_geotrans_affine_lineseg() { int status = (int)f_err.F_ERR_NONE; DSGMT_T src = new DSGMT_T(); // 入力線分. DSGMT_T dst = new DSGMT_T(); // 出力線分. FMATRIX_PTR mat = FMATRIX_PTR.Zero; // 同次変換行列. // 期待値. const double ans_st_x = 2.0606601717798213e+02; const double ans_st_y = 2.3535533905932735e+02; const double ans_ed_x = 1.0000000000000003e+02; const double ans_ed_y = 6.2426406871192842e+02; try { // 同次変換行列の確保. mat = api.fnFIE_mat_aalloc(3, 3); // 同次変換行列の値設定. api.fnFIE_geotrans_calc_rotate_matrix(mat, Math.PI / 4, 100, 200); // 入力線分の設定. src.st.x = 200.0; src.st.y = 150.0; src.ed.x = 400.0; src.ed.y = 500.0; // 処理の実行. status = api.fnFIE_geotrans_affine_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> ''' 入力線分(200, 150)-(400, 500)を、(100, 200)を中心として45度回転させる. ''' 期待値 ''' st.x: 2.0606601717798213e+02 ''' st.y: 2.3535533905932735e+02 ''' ed.x: 1.0000000000000003e+02 ''' ed.y: 6.2426406871192842e+02 ''' </remarks> <FvPluginExecute> _ Public Sub fnFIE_geotrans_affine_lineseg() Dim status As Integer = CInt(f_err.F_ERR_NONE) Dim src As New DSGMT_T() ' 入力線分. Dim dst As New DSGMT_T() ' 出力線分. Dim mat As FMATRIX_PTR = FMATRIX_PTR.Zero ' 同次変換行列. ' 期待値. Const ans_st_x As Double = 206.066017177982 Const ans_st_y As Double = 235.355339059327 Const ans_ed_x As Double = 100.0 Const ans_ed_y As Double = 624.264068711928 Try ' 同次変換行列の確保. mat = api.fnFIE_mat_aalloc(3, 3) ' 同次変換行列の値設定. api.fnFIE_geotrans_calc_rotate_matrix(mat, Math.PI / 4, 100, 200) ' 入力線分の設定. src.st.x = 200.0 src.st.y = 150.0 src.ed.x = 400.0 src.ed.y = 500.0 ' 処理の実行. status = api.fnFIE_geotrans_affine_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 |