The closestPointOnCurve node provides the same functionality for curves as Maya's closestPointOnSurface node does for surfaces. It lets you specify a curve and a point in space, from which it generates the coordinates and U parameter value of the point of the curve which is closest to the point in space. In addition, the distance between the point in space and the closest point on the curve is also calculated and made available.
A closestPointOnCurve node is created like any other node in Maya, using the createNode command. The example below creates a closestPointOnCurve node, a curve, and a locator. It then connects the locator's position and the curve to the closestPointOnCurve node, and retrieves the position, parameter value and distance between the locator and the curve.
// Create the closestPointOnCurve node. createNode -name "cp" closestPointOnCurve; // Create the curve. curve -p -5 -5 0 -p -5 -4 0 -p -3 0 0 -p -2 1 0 -p 2 0 0 -p 4 -1 0 -p 5 -3 0; // Create the locator and move it into position. createNode locator; move -r -5 5 0; // Connect the curve's worldSpace geometry and // the locator's position to the // closestPointOnCurve node connectAttr curve1.worldSpace cp.inputCurve; connectAttr locator1.translate cp.inPosition; // Retrieve the position of the point on curve1 // which is closest to locator1. getAttr cp.position; // Result: -2.302124 0.4814418 0 // // Retrieve the point's U parameter value along // the curve. getAttr cp.parameterU; // Result: 1.606581 // // Retrieve the distance between locator1 and curve1. getAttr cp.distance; // Result: 5.26269 //
The closestPointOnCurve node and its associated materials, which are collectively referred to as "this product", are copyright Gooroos Software, 1999-2004.
Gooroos Software provides this product as-is and assumes no liability for its use. You may freely redistribute it, but only in complete and unmodified form.
If you have any questions or problems with this product, please send email to firstname.lastname@example.org. Because this product is made freely available, we cannot guarantee you a response, but we will try to get back to you as time permits.
For more information on Gooroos Software and our other products, please visit our web-site at www.gooroos.com.