HermiteSpline

A Hermite spline is a cubic interpolating spline. Points, incoming tangents, outgoing tangents, and times must be defined for each control point. The outgoing tangents are defined for points 0, n - 2 and the incoming tangents are defined for points 1, n - 1. For example, when interpolating a segment of the curve between points[i] and points[i + 1], the tangents at the points will be outTangents[i] and inTangents[i], respectively.

// Create a G<sup>1</sup> continuous Hermite spline
const times = [ 0.0, 1.5, 3.0, 4.5, 6.0 ];
const spline = new HermiteSpline({
times : times,
points : [
new Cartesian3(1235398.0, -4810983.0, 4146266.0),
new Cartesian3(1372574.0, -5345182.0, 4606657.0),
new Cartesian3(-757983.0, -5542796.0, 4514323.0),
new Cartesian3(-2821260.0, -5248423.0, 4021290.0),
new Cartesian3(-2539788.0, -4724797.0, 3620093.0)
],
outTangents : [
new Cartesian3(1125196, -161816, 270551),
new Cartesian3(-996690.5, -365906.5, 184028.5),
new Cartesian3(-2096917, 48379.5, -292683.5),
new Cartesian3(-890902.5, 408999.5, -447115)
],
inTangents : [
new Cartesian3(-1993381, -731813, 368057),
new Cartesian3(-4193834, 96759, -585367),
new Cartesian3(-1781805, 817999, -894230),
new Cartesian3(1165345, 112641, 47281)
]
});

const p0 = spline.evaluate(times[0]);

See also

Constructors

Link copied to clipboard
constructor(options: HermiteSpline.ConstructorOptions)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
sealed interface ConstructorOptions

Properties

Link copied to clipboard

An array of incoming tangents at each control point.

Link copied to clipboard

An array of outgoing tangents at each control point.

Link copied to clipboard

An array of control points.

Link copied to clipboard

An array of times for the control points.

Functions

Link copied to clipboard
fun clampTime(time: Double): Double

Clamps the given time to the period covered by the spline.

Link copied to clipboard
fun evaluate(time: Double, result: Cartesian3? = definedExternally): Cartesian3

Evaluates the curve at a given time.

Link copied to clipboard

Finds an index i in times such that the parameter time is in the interval [times[i], times[i + 1]].

Link copied to clipboard
fun wrapTime(time: Double): Double

Wraps the given time to the period covered by the spline.