Merge pull request #426 from Osspial/point_ops
Add vector subtraction for all points
This commit is contained in:
commit
43a6b2be8c
2 changed files with 7 additions and 0 deletions
|
@ -222,9 +222,15 @@ macro_rules! impl_point {
|
|||
impl_operator!(<S: BaseNum> Add<$VectorN<S> > for $PointN<S> {
|
||||
fn add(lhs, rhs) -> $PointN<S> { $PointN::new($(lhs.$field + rhs.$field),+) }
|
||||
});
|
||||
impl_operator!(<S: BaseNum> Sub<$VectorN<S>> for $PointN<S> {
|
||||
fn sub(lhs, rhs) -> $PointN<S> { $PointN::new($(lhs.$field - rhs.$field),+) }
|
||||
});
|
||||
impl_assignment_operator!(<S: BaseNum> AddAssign<$VectorN<S> > for $PointN<S> {
|
||||
fn add_assign(&mut self, vector) { $(self.$field += vector.$field);+ }
|
||||
});
|
||||
impl_assignment_operator!(<S: BaseNum> SubAssign<$VectorN<S>> for $PointN<S> {
|
||||
fn sub_assign(&mut self, vector) { $(self.$field -= vector.$field);+ }
|
||||
});
|
||||
|
||||
impl_operator!(<S: BaseNum> Sub<$PointN<S> > for $PointN<S> {
|
||||
fn sub(lhs, rhs) -> $VectorN<S> { $VectorN::new($(lhs.$field - rhs.$field),+) }
|
||||
|
|
|
@ -319,6 +319,7 @@ pub trait EuclideanSpace: Copy + Clone where
|
|||
Self: Array<Element = <Self as EuclideanSpace>::Scalar>,
|
||||
|
||||
Self: Add<<Self as EuclideanSpace>::Diff, Output = Self>,
|
||||
Self: Sub<<Self as EuclideanSpace>::Diff, Output = Self>,
|
||||
Self: Sub<Self, Output = <Self as EuclideanSpace>::Diff>,
|
||||
|
||||
Self: Mul<<Self as EuclideanSpace>::Scalar, Output = Self>,
|
||||
|
|
Loading…
Reference in a new issue