Merge pull request #1590 from hannobraun/math

Make various improvements to `fj-math`
This commit is contained in:
Hanno Braun 2023-02-15 15:03:23 +01:00 committed by GitHub
commit bf4ca75a6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

View File

@ -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
}

View File

@ -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>>,

View File

@ -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>,