最大空円(最大内接円)の計算

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

Syntax

C#
public static int fnFIE_cg_empty_circle_calc(
	PNT_T_PTR pnts,
	int num,
	ref PNT_T center,
	ref int radius2
)
Visual Basic
Public Shared Function fnFIE_cg_empty_circle_calc ( 
	pnts As PNT_T_PTR,
	num As Integer,
	ByRef center As PNT_T,
	ByRef radius2 As Integer
) As Integer

Parameters

pnts
Type: fvalgcli..::..PNT_T_PTR
点群
num
Type: System..::..Int32
点の数( pnts の要素数)
center
Type: fvalgcli..::..PNT_T%
外接円中心
radius2
Type: System..::..Int32%
外接円半径の2乗

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_PARAM 不正なパラメータが渡された 点群によって生成された凸包の頂点が3点未満 ヌルポインタが渡された
F_ERR_CALC_IMPOSSIBLE 計算不能凸包の内部に中心を持つ円が無い
F_ERR_NOMEMORYメモリ不足
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_empty_circle_calc()
        {
            int status = (int)f_err.F_ERR_NONE;

            PNT_T_PTR pnts = PNT_T_PTR.Zero;// 点群.
            int num;                        // 点の数( pnts の要素数).
            PNT_T center = new PNT_T();        // 外接円中心.
            int radius2 = new int();        // 外接円半径の2乗.

            const int size_x = 32;
            const int size_y = 24;
            const int ans_center_x = size_x / 2;
            const int ans_center_y = size_y / 2;
            const int ans_radius2 = 1;

            try
            {
                // 点群を確保、設定する.
                num = size_x * size_y - 1;
                pnts = PNT_T_PTR.alloc(num);

                {
                    int x = 0; int y = 0;

                    for (int i = 0; i < num; i++)
                    {
                        if (x == ans_center_x && y == ans_center_y) x++;
                        if (x >= size_x)
                        {
                            x = 0; y++;
                        }

                        pnts[i] = PNT_T.init(x, y);

                        x++;
                    }
                }

                // 最大空円(最大内接円)の計算.
                status = api.fnFIE_cg_empty_circle_calc(pnts, num, ref center, ref radius2);

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

                // 結果を出力する.
                ConsoleOut.WriteFunctionName(":\t");
                Console.Write("center=({0}, {1}),  radius2={2} ...", center.x, center.y, radius2);
                ConsoleOut.IsTrue(center.x == ans_center_x && center.y == ans_center_y && radius2 == ans_radius2);
            }
            finally
            {
                pnts.Dispose();
            }
        }
    }
}


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

        Dim pnts As PNT_T_PTR = PNT_T_PTR.Zero
        ' 点群.
        Dim num As Integer
        ' 点の数( pnts の要素数).
        Dim center As New PNT_T()
        ' 外接円中心.
        Dim radius2 As New Integer()
        ' 外接円半径の2乗.
        Const  size_x As Integer = 32
        Const  size_y As Integer = 24
        Const  ans_center_x As Integer = size_x \ 2
        Const  ans_center_y As Integer = size_y \ 2
        Const  ans_radius2 As Integer = 1

        Try
            ' 点群を確保、設定する.
            num = size_x * size_y - 1
            pnts = PNT_T_PTR.alloc(num)

            If True Then
                Dim x As Integer = 0
                Dim y As Integer = 0

                For i As Integer = 0 To num - 1
                    If x = ans_center_x AndAlso y = ans_center_y Then
                        x += 1
                    End If
                    If x >= size_x Then
                        x = 0
                        y += 1
                    End If

                    pnts(i) = PNT_T.init(x, y)

                    x += 1
                Next
            End If

            ' 最大空円(最大内接円)の計算.
            status = api.fnFIE_cg_empty_circle_calc(pnts, num, center, radius2)

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

            ' 結果を出力する.
            ConsoleOut.WriteFunctionName(":" & vbTab)
            Console.Write("center=({0}, {1}),  radius2={2} ...", center.x, center.y, radius2)
            ConsoleOut.IsTrue(center.x = ans_center_x AndAlso center.y = ans_center_y AndAlso radius2 = ans_radius2)
        Finally
            pnts.Dispose()
        End Try
    End Sub
End Class

See Also