splines/b

B-splines

B-splines (short for basis splines) are useful most for the continuity of their derivatives, making them an excellent choice for camera and object movement where smoothness across knots is paramount but exact position is less important.

Types

pub type BSpline(a) {
  BSpline(
    points: vec4.Vec4(a),
    scale: fn(a, Float) -> a,
    sum: fn(List(a)) -> a,
  )
}

Constructors

  • BSpline(
      points: vec4.Vec4(a),
      scale: fn(a, Float) -> a,
      sum: fn(List(a)) -> a,
    )

Values

pub fn new_2d(
  p0: vec2.Vec2(Float),
  p1: vec2.Vec2(Float),
  p2: vec2.Vec2(Float),
  p3: vec2.Vec2(Float),
) -> BSpline(vec2.Vec2(Float))

Constructs a 2d B-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),
) -> BSpline(vec3.Vec3(Float))

Constructs a 3d B-spline, given the four control-points as Vec3fs.

pub fn sample(curve: BSpline(a), t: Float) -> a

Samples any B-spline at time t, where 0.0 <= t <= 1.0 (usually).

Search Document