2直線(2点指定×2)の交点座標と交角の角度の算出

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

Syntax

C#
public static int fnFIE_cg_calc_cross_2lineA(
	DPNT_T pnt1,
	DPNT_T pnt2,
	DPNT_T pnt3,
	DPNT_T pnt4,
	ref DPNT_T cross,
	ref double angle
)
Visual Basic
Public Shared Function fnFIE_cg_calc_cross_2lineA ( 
	pnt1 As DPNT_T,
	pnt2 As DPNT_T,
	pnt3 As DPNT_T,
	pnt4 As DPNT_T,
	ByRef cross As DPNT_T,
	ByRef angle As Double
) As Integer

Parameters

pnt1
Type: fvalgcli..::..DPNT_T
直線L12も求めるための座標点P1
pnt2
Type: fvalgcli..::..DPNT_T
直線L12も求めるための座標点P2
pnt3
Type: fvalgcli..::..DPNT_T
直線L34も求めるための座標点P3
pnt4
Type: fvalgcli..::..DPNT_T
直線L34も求めるための座標点P4
cross
Type: fvalgcli..::..DPNT_T%
2直線が作る交点座標Pc
angle
Type: System..::..Double%
2直線のなす角のうち、小さい方の角度(単位:ラジアン [0,π/2] )

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_PARAM 不正なパラメータが渡された
F_ERR_CALC_IMPOSSIBLE 計算不能エラー
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_cross_2lineA()
        {
            int status = (int)f_err.F_ERR_NONE;

            DPNT_T pts1 = new DPNT_T();
            DPNT_T pts2 = new DPNT_T();
            DPNT_T pts3 = new DPNT_T();
            DPNT_T pts4 = new DPNT_T();
            DPNT_T cross = new DPNT_T();
            double angle = new double();

            const double ans_angle = 41.893972904383;

            // 直線1を構成する座標の設定.
            pts1.x = 30;
            pts1.y = 30;
            pts2.x = 300;
            pts2.y = 300;
            // 直線2を構成する座標の設定.
            pts3.x = 54;
            pts3.y = 163;
            pts4.x = 441;
            pts4.y = 184;

            status = api.fnFIE_cg_calc_cross_2lineA(pts1, pts2, pts3, pts4, ref cross, ref angle);

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

            // 結果を出力する.
            ConsoleOut.WriteFunctionName(":\n");
            Console.WriteLine("cross.x: {0}", cross.x);
            Console.WriteLine("cross.y: {0}", cross.y);
            Console.WriteLine("angle: {0}", angle * 180 / Math.PI);
            Console.Write(" ...");
            ConsoleOut.IsTrue(DblEqual(angle * 180 / Math.PI, ans_angle));
        }
    }
}


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_cross_2lineA()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim pts1 As New DPNT_T()
        Dim pts2 As New DPNT_T()
        Dim pts3 As New DPNT_T()
        Dim pts4 As New DPNT_T()
        Dim cross As New DPNT_T()
        Dim angle As New Double()

        Const  ans_angle As Double = 41.893972904383

        ' 直線1を構成する座標の設定.
        pts1.x = 30
        pts1.y = 30
        pts2.x = 300
        pts2.y = 300
        ' 直線2を構成する座標の設定.
        pts3.x = 54
        pts3.y = 163
        pts4.x = 441
        pts4.y = 184

        status = api.fnFIE_cg_calc_cross_2lineA(pts1, pts2, pts3, pts4, cross, angle)

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

        ' 結果を出力する.
        ConsoleOut.WriteFunctionName(":" & vbLf)
        Console.WriteLine("cross.x: {0}", cross.x)
        Console.WriteLine("cross.y: {0}", cross.y)
        Console.WriteLine("angle: {0}", angle * 180 / Math.PI)
        Console.Write(" ...")
        ConsoleOut.IsTrue(DblEqual(angle * 180 / Math.PI, ans_angle))
    End Sub
End Class

See Also