General Methods
numKnots
Returns the number of knots (also known vertices or control points) in the indexed spline as an integer. If the spline index is not specified, returns the number of knots in the entire shape.
For example:
y = donut()
numKnots y
Interpolation Methods
There are a number of interpolation functions that operate on shape scene objects. They provide capabilities such as stepping along a curve within a shape getting coordinates on the curve, getting curve lengths or determining the closest point on a curve to a given coordinate. These are useful for placing cloned objects along a curve or keeping a set of objects in formation near a 'spine' curve as it animates, etc.
The interpolators all take a shape scene object (for example, a line), an optional curve number in case there are several curves in the shape, defaulting to 1, and a parameter in the range 0.0 to 1.0, that specifies a spot on the curve as a proportion along its length. There are two types of interpolator provided:
One interpolator matches the 3ds Max Path controller in which the percentage along the path is not uniform, but weighted by the vertex spacing. This simple interpolation is interpolating based on parameter space. If a spline has 4 segments, the first segment is parameter values 0-0.25, the second 0.25-0.5, the third 0.5-0.75 and the fourth 0.75-1.0. This is regardless of the length of each segment.
Another interpolator that gives you a uniform interpolation along the length of the curve. This interpolation normalizes the parameter space to distance along the length of a spline. So parameter space 0 is the start, 1.0 is the end and 0.5 is halfway along the actual length of the curve.
The non-uniform Path interpolator in 3ds Max gives rise to the varying velocity of a path-animated object when the path has unevenly spaced control points. The arc-length interpolators provided here give a uniform placing along the curve no matter how uneven the control point placement. The advantage of the Path interpolator is that it is computationally much more efficient than a uniform arc-length interpolator. The length interpolator uses some caches to speed it up, but you have to help manage them in the way described below.
The optional steps: keyword argument for the methods listed below lets you specify the integration steps. The default steps value is 5 times the curve's 3ds Max unit length, which usually is more than enough. For example, if a curve has a length of 100 3ds Max units, the default step size would be 500. The interpolation algorithm has an accuracy of no better than + or - (1/steps) 3ds Max units. These methods employ a cache to speed up their operation in the common case where you step gradually along a single curve. The cache remembers the state for the last point on the curve and picks up there if you call again on the same curve at the same animation time. This can exponentially speed up interpolation processing. However, MAXScript does not have a way of knowing if you've edited the curve from one call to the next, so you have to be sure to reset the cache with the resetLengthInterp() method if the user can edit the curve between calls in your code.
All coordinates are in the current coordinate system.
Return a point3 coordinate on the numbered curve (defaults to 1) corresponding to the parameter value (0.0 to 1.0) that matches the 3ds Max Path controller percentage (vertex-based) interpolation.
lengthInterp
Return a point3 coordinate on the numbered curve (defaults to 1) corresponding to the parameter value (0.0 to 1.0) that is that fraction along the curve's total length.
resetLengthInterp()
Clear length interpolation cache. Use this if the curve you are length-interpolating along might have been edited between calls.
curveLength
Return the arc length of the numbered curve. This length does not reflect any transform level scaling performed on the shape.
pathTangent
Return the tangent direction vector at the 3ds Max Path (vertex-based) interpolated point along the specified curve. You can use this function, for example, to set an object's direction to follow the curve.
lengthTangent
Return the tangent direction vector at the arc-length-interpolated point along the specified curve. You can use this function to set an object's direction to follow the curve.
nearestPathParam
Return the interpolation
parameter value (0.0 to 1.0) corresponding to the point along the
curve that is closest to the given
pathToLengthParam
Return the uniform arc-length length parameter corresponding to the given 3ds Max Path (vertex-based) parameter for this curve.
lengthToPathParam
Return the 3ds Max Path (vertex-based) parameter corresponding to the given uniform arc-length parameter for this curve.
See also
Node Common Properties, Operators, and Methods