Added point * vector

This commit is contained in:
Yuri Edward 2021-10-21 15:47:00 +02:00
parent 99704a0ea1
commit 4466fb2514
1 changed files with 29 additions and 3 deletions

View File

@ -4,7 +4,7 @@ use simba::scalar::ClosedMul;
use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint};
use crate::base::dimension::U1; use crate::base::dimension::U1;
use crate::base::{Const, Scalar}; use crate::base::{Const, SVector, Scalar};
use crate::geometry::{Point, Scale}; use crate::geometry::{Point, Scale};
@ -51,8 +51,6 @@ add_sub_impl!(Mul, mul, ClosedMul;
#[allow(clippy::suspicious_arithmetic_impl)] { Scale::from(self.vector * right) }; ); #[allow(clippy::suspicious_arithmetic_impl)] { Scale::from(self.vector * right) }; );
// Scale × Point // Scale × Point
// TODO: we don't handle properly non-zero origins here. Do we want this to be the intended
// behavior?
add_sub_impl!(Mul, mul, ClosedMul; add_sub_impl!(Mul, mul, ClosedMul;
(Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1) (Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
const D; for; where; const D; for; where;
@ -91,3 +89,31 @@ add_sub_assign_impl!(MulAssign, mul_assign, ClosedMul;
const D; const D;
self: Scale<T, D>, right: Scale<T, D>; self: Scale<T, D>, right: Scale<T, D>;
#[allow(clippy::suspicious_op_assign_impl)] { self.vector.component_mul_assign(&right.vector); }; ); #[allow(clippy::suspicious_op_assign_impl)] { self.vector.component_mul_assign(&right.vector); }; );
// Point * Vector
add_sub_impl!(Mul, mul, ClosedMul;
(Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
const D; for; where;
self: &'a Point<T, D>, right: &'b SVector<T, D>, Output = Point<T, D>;
#[allow(clippy::suspicious_arithmetic_impl)] { Point::from(self.coords.component_mul(&right)) };
'a, 'b);
add_sub_impl!(Mul, mul, ClosedMul;
(Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
const D; for; where;
self: &'a Point<T, D>, right: SVector<T, D>, Output = Point<T, D>;
#[allow(clippy::suspicious_arithmetic_impl)] { Point::from(self.coords.component_mul(&right)) };
'a);
add_sub_impl!(Mul, mul, ClosedMul;
(Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
const D; for; where;
self: Point<T, D>, right: &'b SVector<T, D>, Output = Point<T, D>;
#[allow(clippy::suspicious_arithmetic_impl)] { Point::from(self.coords.component_mul(&right)) };
'b);
add_sub_impl!(Mul, mul, ClosedMul;
(Const<D>, U1), (Const<D>, U1) -> (Const<D>, U1)
const D; for; where;
self: Point<T, D>, right: SVector<T, D>, Output = Point<T, D>;
#[allow(clippy::suspicious_arithmetic_impl)] { Point::from(self.coords.component_mul(&right)) }; );