NurbsSurfaceMesh.GetClosestSurfacePosition2
 
 
 

NurbsSurfaceMesh.GetClosestSurfacePosition2 operator

Description

Returns the surface index, position of the point on it, UV values and squared distance from the given position. The data is returned in a 1-dimensional array and is ordered the same as for the NurbsSurfaceMesh.GetClosestSurfacePosition method output arguments.

Note: This method must be used with scripting languages that don't support arguments passed by reference such as JScript and PerlScript. For more information on getting output arguments, see About Output Argument Arrays.

C# Syntax

Object NurbsSurfaceMesh.GetClosestSurfacePosition2( Object in_vPosition );

Scripting Syntax

oArray = NurbsSurfaceMesh.GetClosestSurfacePosition2( Position );

Return Value

Array of Variants ordered as Index, SquaredDistance, UValue, VValue, Position.

Parameters

Parameter Type Description
Position SIVector3 or 1D Array of 3 elements A position expressed in the NurbsSurfaceMesh object frame of reference.

Examples

JScript Example

// This example shows how to retrieve the control points returned by 
// NurbsSurface.GetClosestSurfacePosition2
var oRoot = Application.ActiveProject.ActiveScene.Root;
var oSphere = oRoot.AddGeometry( "Sphere", "NurbsSurface" );
// Translate the sphere
oSphere.Kinematics.Global.Parameters("posx").value = oSphere.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(oSphere.ActivePrimitive.Geometry.GetClosestSurfacePosition2(oPosition));
var args = vbArgs.toArray();
LogMessage( "The origin is closest to surface : " + args[0] + " its distance from it is " + Math.sqrt(args[1]) );
LogMessage( "The UV values are U : " + args[2] + " V :" + args[3] );
LogMessage( "The corresponding position is X : " + args[4].X + " Y :" + args[4].Y + " Z :" + args[4].Z );

See Also

NurbsSurfaceMesh.GetClosestSurfacePosition