Skip to content

Commit

Permalink
Change order of impl blocks
Browse files Browse the repository at this point in the history
In other places, the generic `impl` block is put first, followed by the
specific ones.
  • Loading branch information
hannobraun committed Jun 13, 2022
1 parent cc255d6 commit 4df44b3
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions crates/fj-kernel/src/geometry/curves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,43 +26,6 @@ pub enum Curve<const D: usize> {
Line(Line<D>),
}

impl Curve<3> {
/// Construct a `Curve` that represents the x-axis
pub fn x_axis() -> Self {
Self::Line(Line {
origin: Point::origin(),
direction: Vector::unit_x(),
})
}

/// Construct a `Curve` that represents the y-axis
pub fn y_axis() -> Self {
Self::Line(Line {
origin: Point::origin(),
direction: Vector::unit_y(),
})
}

/// Construct a `Curve` that represents the z-axis
pub fn z_axis() -> Self {
Self::Line(Line {
origin: Point::origin(),
direction: Vector::unit_z(),
})
}

/// Create a new instance that is transformed by `transform`
#[must_use]
pub fn transform(self, transform: &Transform) -> Self {
match self {
Self::Circle(curve) => {
Self::Circle(transform.transform_circle(&curve))
}
Self::Line(curve) => Self::Line(transform.transform_line(&curve)),
}
}
}

impl<const D: usize> Curve<D> {
/// Access the origin of the curve's coordinate system
pub fn origin(&self) -> Point<D> {
Expand Down Expand Up @@ -129,6 +92,43 @@ impl<const D: usize> Curve<D> {
}
}

impl Curve<3> {
/// Construct a `Curve` that represents the x-axis
pub fn x_axis() -> Self {
Self::Line(Line {
origin: Point::origin(),
direction: Vector::unit_x(),
})
}

/// Construct a `Curve` that represents the y-axis
pub fn y_axis() -> Self {
Self::Line(Line {
origin: Point::origin(),
direction: Vector::unit_y(),
})
}

/// Construct a `Curve` that represents the z-axis
pub fn z_axis() -> Self {
Self::Line(Line {
origin: Point::origin(),
direction: Vector::unit_z(),
})
}

/// Create a new instance that is transformed by `transform`
#[must_use]
pub fn transform(self, transform: &Transform) -> Self {
match self {
Self::Circle(curve) => {
Self::Circle(transform.transform_circle(&curve))
}
Self::Line(curve) => Self::Line(transform.transform_line(&curve)),
}
}
}

impl<const D: usize> fmt::Display for Curve<D> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Expand Down

0 comments on commit 4df44b3

Please sign in to comment.