NurbsCurveList.GetClosestCurvePosition2

NurbsCurveList.GetClosestCurvePosition2 operator

説明

カーブのインデックス、カーブ上のポイントの位置、U値および指定された位置からの距離の 2乗を戻します。データは 1D 配列で戻されます。順序は NurbsCurveList.GetClosestCurvePosition メソッドの出力引数と同じです。

注:このメソッドは、JScriptやPerlScriptなどの引数の参照渡しをサポートしないスクリプト言語で使用する必要があります。出力引数の取得の詳細については、About Output Argument Arrays を参照してください。

C#構文

Object NurbsCurveList.GetClosestCurvePosition2( Object in_vPosition );

スクリプト構文

oArray = NurbsCurveList.GetClosestCurvePosition2( Position );

戻り値

カーブのインデックス(Long)、指定された位置からの距離の 2乗(Double)、U値(Double)、およびカーブ上のポイントの位置(SIVector3)を含むArray

パラメータ

パラメータ タイプ 説明
Position SIVector3または 3 つのエレメントからなる 1DArray NurbsCurveList オブジェクトの参照フレームとして表現される位置

1. JScript の例

// This example shows how to retrieve the control points returned by

// NurbsSurface.GetClosestSurfacePosition2

var oRoot = Application.ActiveProject.ActiveScene.Root;

var oArc = oRoot.AddGeometry( "Arc", "NurbsCurve" );

// Translate the sphere

oArc.Kinematics.Global.Parameters("posx").value = oArc.Kinematics.Global.Parameters("posx").value + 13;

var oPosition = XSIMath.CreateVector3();

oPosition.Set( 0.0, 0.0, 0.0 );

// convert VB array to JScript array

var vbArgs = new VBArray(oArc.ActivePrimitive.Geometry.GetClosestCurvePosition2(oPosition));

var args = vbArgs.toArray();

LogMessage( "The origin is closest to curve : " + args[0] + " its distance from it is " + Math.sqrt(args[1]) );

LogMessage( "The U values are U : " + args[2] );

LogMessage( "The corresponding position is X: " + args[3].X + " Y: " + args[3].Y + " Z: " + args[3].Z );

2. JScript の例

/*

	This example demonstrates how to work with curve lists. Of particular

	interest is how to use the (object model) equivalents of EvaluateCurveAt.

*/

NewScene( null, false );

// Create a NurbsCurveList

var oSpine = SICreateCurve( "crvlist", 3, 0 );

SIAddPointOnCurveAtEnd( "crvlist", -10, 0, -3, false, 0 );

SIAddPointOnCurveAtEnd( "crvlist", 10, 0, -3, false, 0 );

var oUKnots = oSpine.ActivePrimitive.Geometry.Curves(0).Knots 

LogMessage( "Start Knot " + oUKnots.item(0 ) )

LogMessage( "End Knot " + oUKnots.item( oUKnots.Count - 1 ) )

var xxx = 0;

var vP = XSIMath.CreateVector3();

var n;

for ( var i=-10; i<=10; i+=0.2 ) {

	LogMessage( "----------------" );

	vP.Set( i,0,-3 );

	var Args = oSpine .ActivePrimitive.Geometry.GetClosestCurvePosition2( vP ).toArray();

	uClosest = Args[2];

	var atmp = oSpine.ActivePrimitive.Geometry.Curves( 0 ).EvaluatePosition( uClosest ).toArray();

	LogMessage( "Closest U Value " + uClosest )

	var ZeValues = atmp[0]

	LogMessage( ZeValues.x );

	// this is the null that corresponds to the closest point found

	n = ActiveSceneRoot.AddNull();

	n.Kinematics.Global.Parameters( "posx" ).Value = ZeValues.x;

	// parallel null

	n = ActiveSceneRoot.AddNull();

	n.Kinematics.Global.Parameters( "posx" ).Value = i;

	n.Kinematics.Global.Parameters( "posy" ).Value = -3;

	// this value steadily increases!!!

	DiffFromLast = uClosest - xxx;

	LogMessage( uClosest + " diff from last: " + DiffFromLast );

	xxx = uClosest;

}

// output:

//INFO : Start Knot 0

//INFO : End Knot 1

//INFO : ----------------

//INFO : Closest U Value 0

//INFO : -10

//INFO : 0 diff from last: 0

//INFO : ----------------

//INFO : Closest U Value 0.0033442415690163336

//INFO : -9.80001579492262

//INFO : 0.0033442415690163336 diff from last: 0.0033442415690163336

//INFO : ----------------

//INFO : Closest U Value 0.006710593551987059

//INFO : -9.60006026699216

//INFO : 0.006710593551987059 diff from last: 0.0033663519829707257

//INFO : ----------------

//		etc.

//INFO : ----------------

//INFO : Closest U Value 0.7842420051901503

//INFO : 9.79912278091057

//INFO : 0.7842420051901503 diff from last: 0.05569420207796605

//INFO : ----------------

//INFO : Closest U Value 0.999999999999987

//INFO : 10

//INFO : 0.999999999999987 diff from last: 0.2157579948098367

関連項目

NurbsCurveList.GetClosestCurvePosition NurbsCurve.EvaluatePosition EvaluateCurveAt