new CatmullRomSpline
A Catmull-Rom spline is a cubic spline where the tangent at control points, except the first and last, are computed using the previous and next control points. Catmull-Rom splines are in the class C1.
Parameters:
Name | Type | Description |
---|---|---|
controlPoints |
Array | The array of control points. Each element of the array should be an object with point and time properties. |
firstTangent |
Cartesian3 | The tangent of the curve at the first control point. If the tangent is not given, it will be estimated. |
lastTangent |
Cartesian3 | The tangent of the curve at the last control point. If the tangent is not given, it will be estimated. |
Throws:
-
DeveloperError : controlPoints is required.
-
DeveloperError : controlPoints must be an array of at least length 3.
Example
// spline above the earth from Philadelphia to Los Angeles var controlPoints = [ {point: new Cartesian3(1235398.0, -4810983.0, 4146266.0), time: 0.0}, {point: new Cartesian3(1372574.0, -5345182.0, 4606657.0), time: 1.5}, {point: new Cartesian3(-757983.0, -5542796.0, 4514323.0), time: 3.0}, {point: new Cartesian3(-2821260.0, -5248423.0, 4021290.0), time: 4.5}, {point: new Cartesian3(-2539788.0, -4724797.0, 3620093.0), time: 6.0} ]; var spline = new CatmullRomSpline(controlPoints);
See:
Source:
Methods
-
evaluate
-
Evaluates the curve at a given time.
Parameters:
Name Type Description time
Number The time at which to evaluate the curve. Throws:
-
DeveloperError : time is required.
-
DeveloperError : time must be in the range
[a0, an]
, wherea0
andan
are the time properties of first and last elements in the array given during construction, respectively.
Returns:
Cartesian3 The point on the curve at the giventime
.Example
// spline above the earth from Philadelphia to Los Angeles var controlPoints = [ {point: new Cartesian3(1235398.0, -4810983.0, 4146266.0), time: 0.0}, {point: new Cartesian3(1372574.0, -5345182.0, 4606657.0), time: 1.5}, {point: new Cartesian3(-757983.0, -5542796.0, 4514323.0), time: 3.0}, {point: new Cartesian3(-2821260.0, -5248423.0, 4021290.0), time: 4.5}, {point: new Cartesian3(-2539788.0, -4724797.0, 3620093.0), time: 6.0} ]; var spline = new CatmullRomSpline(controlPoints); // some position above Los Angeles var position = spline.evaluate(5.0);
-
-
getControlPoints
-
Returns the array of control points.
Returns:
Array The array of control points. -
getEndTangent
-
Returns the tangent of the last control point.
Returns:
Cartesian3 The tangent of the last control point. -
getStartTangent
-
Returns the tangent of the first control point.
Returns:
Cartesian3 The tangent of the first control point.