API Reference · Math utilities
Spline
public static class SplineA smooth curve through a row of points, and the direction it is going when it gets there.
The problem is always the same shape: there are waypoints, and something has to move between them without stopping at each one. A camera move, a flight path, a spine to extrude a tube along, a track of scalars driving an angle. Linear interpolation gives a corner at every waypoint; a Bézier wants control handles nobody has; a B-spline does not pass through its own points. Catmull–Rom passes through every point it is given, needs nothing but the points, and is C¹ — which is the combination that made it the default for exactly this job in every engine that has one.
Uniform in the parameter, not in arc length. Each segment gets an equal share of t however long it is, so waypoint i is always reached at i / (n − 1) and placing something somewhere at a particular moment is a matter of counting waypoints. The cost is that a long segment is travelled faster than a short one. Arc-length parameterisation is the other trade — even speed, timing you have to solve for — and it needs a sampled length table, an allocation and a lifetime to hang it on. Nothing here has one, so it is not offered: spacing the waypoints evenly is the answer that costs nothing, and it is the answer nearly every caller wants anyway.
Everything is a static function of an array. No object to build, no state to invalidate when the array changes, and the same array can be sampled by anything that can see it.
Methods
| Member | Description |
|---|---|
| Which way the curve is heading at This is what orients something that follows a path: Where the curve is momentarily stationary there is no direction to give, and this returns |
| The point at
|
| The same curve through a row of plain numbers: an animation track, a roll angle, an opacity. |
| How fast the curve is moving at This is the analytic derivative, not a secant between two nearby samples. The difference is not accuracy so much as honesty: a numerical derivative needs a step size, and the step size is a number that has to be small enough to be a derivative and large enough not to be rounding noise, which is a tuning parameter nobody should have to own. The length is zero where the curve is momentarily stationary, so normalise with care — |
| The rate of change of a scalar track at There is no |