/*
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 |