Add Sub and SubAssign <Vector> for all Points
This commit is contained in:
parent
b270f9fb52
commit
4580cb3aca
1 changed files with 6 additions and 0 deletions
|
@ -198,9 +198,15 @@ macro_rules! impl_point {
|
||||||
impl_operator!(<S: BaseNum> Add<$VectorN<S> > for $PointN<S> {
|
impl_operator!(<S: BaseNum> Add<$VectorN<S> > for $PointN<S> {
|
||||||
fn add(lhs, rhs) -> $PointN<S> { $PointN::new($(lhs.$field + rhs.$field),+) }
|
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> {
|
impl_assignment_operator!(<S: BaseNum> AddAssign<$VectorN<S> > for $PointN<S> {
|
||||||
fn add_assign(&mut self, vector) { $(self.$field += vector.$field);+ }
|
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> {
|
impl_operator!(<S: BaseNum> Sub<$PointN<S> > for $PointN<S> {
|
||||||
fn sub(lhs, rhs) -> $VectorN<S> { $VectorN::new($(lhs.$field - rhs.$field),+) }
|
fn sub(lhs, rhs) -> $VectorN<S> { $VectorN::new($(lhs.$field - rhs.$field),+) }
|
||||||
|
|
Loading…
Reference in a new issue