splines/catmull_rom
Centripetal Catmull-Rom splines
Catmull-Rom splines are useful for paths of objects because they preserve velocity through points on the path. This implementation uses the “centripetal” formulation that requires 4 control points, with the curve spanning the two central points.
Types
Values
pub fn new_2d(
p0: vec2.Vec2(Float),
p1: vec2.Vec2(Float),
p2: vec2.Vec2(Float),
p3: vec2.Vec2(Float),
) -> CatmullRom(vec2.Vec2(Float))
Constructs a 2d Catmull-Rom spline, given the four control-points as Vec2fs.
pub fn new_3d(
p0: vec3.Vec3(Float),
p1: vec3.Vec3(Float),
p2: vec3.Vec3(Float),
p3: vec3.Vec3(Float),
) -> CatmullRom(vec3.Vec3(Float))
Constructs a 3d Catmull-Rom spline, given the four control-points as Vec3fs.
pub fn sample(curve: CatmullRom(a), t: Float) -> a
Samples any Catmull-Rom spline at time t, where 0.0 <= t <= 1.0 (usually).