2点を通る直線と点までの距離と中点座標の算出(3点指定)

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

Syntax

C#
public static int fnFIE_cg_calc_center_point_and_lineA(
	DPNT_T pnt1,
	DPNT_T pnt2,
	DPNT_T pnt3,
	ref DPNT_T center,
	ref double dist
)
Visual Basic
Public Shared Function fnFIE_cg_calc_center_point_and_lineA ( 
	pnt1 As DPNT_T,
	pnt2 As DPNT_T,
	pnt3 As DPNT_T,
	ByRef center As DPNT_T,
	ByRef dist As Double
) As Integer

Parameters

pnt1
Type: fvalgcli..::..DPNT_T
直線を決定する座標点P1
pnt2
Type: fvalgcli..::..DPNT_T
直線を決定する座標点P2
pnt3
Type: fvalgcli..::..DPNT_T
直線との距離を求める座標点P3
center
Type: fvalgcli..::..DPNT_T%
直線と点3との中点座標Pc
dist
Type: System..::..Double%
直線と点3との距離d

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

            DPNT_T pnt1 = new DPNT_T();
            DPNT_T pnt2 = new DPNT_T();
            DPNT_T pnt3 = new DPNT_T();
            DPNT_T center = new DPNT_T();
            double dist = new double();

            const double ans_dist = 260.89624533275;

            // 座標の設定.
            pnt1.x = 100;
            pnt1.y = 30;
            pnt2.x = 400;
            pnt2.y = 300;
            pnt3.x = 10;
            pnt3.y = 300;

            status = api.fnFIE_cg_calc_center_point_and_lineA(pnt1, pnt2, pnt3, ref center, ref dist);

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

            // 結果を出力する.
            ConsoleOut.WriteFunctionName(":\n");
            Console.WriteLine("center = ({0},{1}), dist = {2}", center.x, center.y, dist);
            Console.Write(" ...");
            ConsoleOut.IsTrue(DblEqual(dist, ans_dist));
        }
    }
}


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

        Dim pnt1 As New DPNT_T()
        Dim pnt2 As New DPNT_T()
        Dim pnt3 As New DPNT_T()
        Dim center As New DPNT_T()
        Dim dist As New Double()

        Const  ans_dist As Double = 260.89624533275

        ' 座標の設定.
        pnt1.x = 100
        pnt1.y = 30
        pnt2.x = 400
        pnt2.y = 300
        pnt3.x = 10
        pnt3.y = 300

        status = api.fnFIE_cg_calc_center_point_and_lineA(pnt1, pnt2, pnt3, center, dist)

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

        ' 結果を出力する.
        ConsoleOut.WriteFunctionName(":" & vbLf)
        Console.WriteLine("center = ({0},{1}), dist = {2}", center.x, center.y, dist)
        Console.Write(" ...")
        ConsoleOut.IsTrue(DblEqual(dist, ans_dist))
    End Sub
End Class

See Also