Skip to content

Commit

Permalink
bezier cubic curve
Browse files Browse the repository at this point in the history
  • Loading branch information
Nertsal committed Oct 12, 2024
1 parent fa99ed4 commit ea1db0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion crates/ctl-core/src/interpolation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub enum Interpolation<T> {
Linear(Vec<T>),
Spline(Spline<T>),
BezierQuadratic(Bezier<3, T>),
// BezierCubic(),
BezierCubic(Bezier<4, T>),
}

impl<T: 'static + Interpolatable> Interpolation<T> {
Expand All @@ -27,6 +27,10 @@ impl<T: 'static + Interpolatable> Interpolation<T> {
Self::BezierQuadratic(Bezier::new(&points))
}

pub fn bezier_cubic(points: Vec<T>) -> Self {
Self::BezierCubic(Bezier::new(&points))
}

/// Get an interpolated value on the given interval.
pub fn get(&self, interval: usize, t: Time) -> Option<T> {
match self {
Expand All @@ -37,6 +41,7 @@ impl<T: 'static + Interpolatable> Interpolation<T> {
}
Self::Spline(i) => i.get(interval, t),
Self::BezierQuadratic(i) => i.get(interval, t),
Self::BezierCubic(i) => i.get(interval, t),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ctl-core/src/model/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl TrajectoryInterpolation {
Self::Linear => Interpolation::linear(points),
Self::Spline { tension } => Interpolation::spline(points, tension.as_f32()),
Self::BezierQuadratic => Interpolation::bezier_quadratic(points),
Self::BezierCubic => todo!(),
Self::BezierCubic => Interpolation::bezier_cubic(points),
}
}
}
Expand Down

0 comments on commit ea1db0f

Please sign in to comment.