Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cubic prefix to all cubic curve generators #10299

Merged
merged 2 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions crates/bevy_math/src/cubic_splines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ impl<P: Point> CubicGenerator<P> for CubicBezier<P> {
/// let hermite = Hermite::new(points, tangents).to_curve();
aevyrie marked this conversation as resolved.
Show resolved Hide resolved
/// let positions: Vec<_> = hermite.iter_positions(100).collect();
/// ```
pub struct Hermite<P: Point> {
pub struct CubicHermite<P: Point> {
control_points: Vec<(P, P)>,
}
impl<P: Point> Hermite<P> {
impl<P: Point> CubicHermite<P> {
/// Create a new Hermite curve from sets of control points.
pub fn new(
control_points: impl IntoIterator<Item = P>,
Expand All @@ -137,7 +137,7 @@ impl<P: Point> Hermite<P> {
}
}
}
impl<P: Point> CubicGenerator<P> for Hermite<P> {
impl<P: Point> CubicGenerator<P> for CubicHermite<P> {
#[inline]
fn to_curve(&self) -> CubicCurve<P> {
let char_matrix = [
Expand Down Expand Up @@ -187,12 +187,12 @@ impl<P: Point> CubicGenerator<P> for Hermite<P> {
/// let cardinal = CardinalSpline::new(0.3, points).to_curve();
aevyrie marked this conversation as resolved.
Show resolved Hide resolved
/// let positions: Vec<_> = cardinal.iter_positions(100).collect();
/// ```
pub struct CardinalSpline<P: Point> {
pub struct CubicCardinalSpline<P: Point> {
tension: f32,
control_points: Vec<P>,
}

impl<P: Point> CardinalSpline<P> {
impl<P: Point> CubicCardinalSpline<P> {
/// Build a new Cardinal spline.
pub fn new(tension: f32, control_points: impl Into<Vec<P>>) -> Self {
Self {
Expand All @@ -209,7 +209,7 @@ impl<P: Point> CardinalSpline<P> {
}
}
}
impl<P: Point> CubicGenerator<P> for CardinalSpline<P> {
impl<P: Point> CubicGenerator<P> for CubicCardinalSpline<P> {
#[inline]
fn to_curve(&self) -> CubicCurve<P> {
let s = self.tension;
Expand Down Expand Up @@ -255,18 +255,18 @@ impl<P: Point> CubicGenerator<P> for CardinalSpline<P> {
/// let b_spline = BSpline::new(points).to_curve();
aevyrie marked this conversation as resolved.
Show resolved Hide resolved
/// let positions: Vec<_> = b_spline.iter_positions(100).collect();
/// ```
pub struct BSpline<P: Point> {
pub struct CubicBSpline<P: Point> {
control_points: Vec<P>,
}
impl<P: Point> BSpline<P> {
impl<P: Point> CubicBSpline<P> {
/// Build a new Cardinal spline.
pub fn new(control_points: impl Into<Vec<P>>) -> Self {
Self {
control_points: control_points.into(),
}
}
}
impl<P: Point> CubicGenerator<P> for BSpline<P> {
impl<P: Point> CubicGenerator<P> for CubicBSpline<P> {
#[inline]
fn to_curve(&self) -> CubicCurve<P> {
let char_matrix = [
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_math/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ pub mod prelude {
#[doc(hidden)]
pub use crate::{
cubic_splines::{
BSpline, CardinalSpline, CubicBezier, CubicGenerator, CubicSegment, Hermite,
CubicBSpline, CubicBezier, CubicCardinalSpline, CubicGenerator, CubicHermite,
CubicSegment,
},
BVec2, BVec3, BVec4, EulerRot, IRect, IVec2, IVec3, IVec4, Mat2, Mat3, Mat4, Quat, Ray,
Rect, URect, UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3, Vec3Swizzles, Vec4,
Expand Down
Loading