H3DU.PiecewiseCurve

Back to documentation index.

### new H3DU.PiecewiseCurve(curves)

Augments: Curve

A curve evaluator object for a curve made up of one or more individual curves.

The combined curve’s U coordinates range from 0 to N, where N is the number of curves. In this way, the integer part of a U coordinate indicates the curve the coordinate refers to. For example, if there are four curves, coordinates from 0, but less than 1, belong to the first curve, and coordinates from 1, but less than 2, belong to the second curve. The U coordinate equal to N refers to the end of the last curve in the piecewise curve.

Parameters

Examples

// Generates a piecewise polygon curve from an array of
// vectors (arrays with the same number of elements) that
// specify the points that make up the polygon.
function polygonCurve(points) {
var curves=[]
for(var i=0;<points.length;i++) {
var cp=points[i]
var np=(i==points.length-1) ? points[0] : points[i+1]
curves.push(BSplineCurve.fromBezierCurve([cp,np]))
}
return new PiecewiseCurve(curves)
}

Methods

### H3DU.PiecewiseCurve#arcLength(u)

Finds an approximate arc length (distance) between the start of this curve and the point at the given U coordinate of this curve.

Parameters

Return Value

The approximate arc length of this curve at the given U coordinate. (Type: number)

### H3DU.PiecewiseCurve#endPoints()

Returns the starting and ending U coordinates of this curve.

Return Value

A two-element array. The first element is the starting coordinate of the curve, and the second is its ending coordinate. Returns [0, n], where n is the number of curves that make up this piecewise curve.

### H3DU.PiecewiseCurve#evaluate(u)

Finds the position of this curve at the given U coordinate.

Parameters

Return Value

An array describing a position. It should have at least as many elements as the number of dimensions of the underlying curve. (Type: Array.<number>)

### (static) H3DU.PiecewiseCurve.fromCatmullRomSpline(spline, [param], [closed])

Creates a piecewise curve made up of B-spline curves from the control points of a cubic Catmull–Rom spline. A Catmull–Rom spline is defined by a collection of control points that the spline will go through, and the shape of each curve segment is also determined by the positions of neighboring points on the spline.

Parameters

Return Value

A piecewise curve made up of cubic B-spline curves describing the same path as the Catmull–Rom spline. (Type: PiecewiseCurve)

### (static) H3DU.PiecewiseCurve.fromEllipseArc(x, y, radiusX, radiusY, start, sweep)

TODO: Not documented yet.

Parameters

Return Value

Return value. (Type: PiecewiseCurve)

### (static) H3DU.PiecewiseCurve.fromHermiteSpline(spline)

Creates a piecewise curve made up of B-spline curves from the control points of a Hermite spline. A Hermite spline is a collection of points that the curve will go through, together with the velocity vectors (derivatives or instantaneous rates of change) at those points.

Hermite splines are useful for representing an approximate polynomial form of a function or curve whose derivative is known; however, Hermite splines are not guaranteed to preserve the increasing or decreasing nature of the function or curve.

Parameters

Return Value

A piecewise curve made up of cubic B-spline curves describing the same path as the Hermite spline. (Type: PiecewiseCurve)

### (static) H3DU.PiecewiseCurve.fromTCBSpline(spline, [tension], [continuity], [bias], [closed], [rigidEnds])

Creates a piecewise curve made up of B-spline curves from the control points of a cubic TCB spline (tension/continuity/bias spline, also known as Kochanek–Bartels spline). (If tension, continuity, and bias are all 0, the result is a cubic Catmull–Rom spline in uniform parameterization.)

Parameters

Return Value

A piecewise curve made up of cubic B-spline curves describing the same path as the TCB spline. (Type: PiecewiseCurve)

### H3DU.PiecewiseCurve#getCurves()

Gets a reference to the curves that make up this piecewise curve.

Return Value

The curves that make up this piecewise curve. (Type: Array.<Curve>)

### H3DU.PiecewiseCurve#velocity(u)

Finds an approximate velocity vector at the given U coordinate of this curve.

Parameters

Return Value

An array describing a velocity vector. It should have at least as many elements as the number of dimensions of the underlying curve. (Type: Array.<number>)

Back to documentation index.