Add Sub and SubAssign <Vector> for all Points

This commit is contained in:
Osspial 2017-08-09 14:12:51 -04:00
parent b270f9fb52
commit 4580cb3aca

View file

@ -198,9 +198,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),+) }