Skip to content

Commit

Permalink
Merge pull request #1590 from hannobraun/math
Browse files Browse the repository at this point in the history
Make various improvements to `fj-math`
  • Loading branch information
hannobraun authored Feb 15, 2023
2 parents f835ba0 + b4c1775 commit bf4ca75
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/fj-math/src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl<const D: usize> Line<D> {
/// Create a new instance that is reversed
#[must_use]
pub fn reverse(mut self) -> Self {
self.origin += self.direction;
self.direction = -self.direction;
self
}
Expand Down
9 changes: 9 additions & 0 deletions crates/fj-math/src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@ where
}
}

impl<V, const D: usize> ops::AddAssign<V> for Point<D>
where
V: Into<Vector<D>>,
{
fn add_assign(&mut self, rhs: V) {
*self = *self + rhs;
}
}

impl<V, const D: usize> ops::Sub<V> for Point<D>
where
V: Into<Vector<D>>,
Expand Down
9 changes: 9 additions & 0 deletions crates/fj-math/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,15 @@ where
}
}

impl<S, const D: usize> ops::MulAssign<S> for Vector<D>
where
S: Into<Scalar>,
{
fn mul_assign(&mut self, rhs: S) {
*self = *self * rhs;
}
}

impl<S, const D: usize> ops::Div<S> for Vector<D>
where
S: Into<Scalar>,
Expand Down

0 comments on commit bf4ca75

Please sign in to comment.