From 4466fb25148654a5dfbcec9e32f76503f7d25a0f Mon Sep 17 00:00:00 2001 From: Yuri Edward Date: Thu, 21 Oct 2021 15:47:00 +0200 Subject: [PATCH] Added point * vector --- src/geometry/scale_ops.rs | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/geometry/scale_ops.rs b/src/geometry/scale_ops.rs index 6a55cf40..df42e9bc 100644 --- a/src/geometry/scale_ops.rs +++ b/src/geometry/scale_ops.rs @@ -4,7 +4,7 @@ use simba::scalar::ClosedMul; use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint}; use crate::base::dimension::U1; -use crate::base::{Const, Scalar}; +use crate::base::{Const, SVector, Scalar}; 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) }; ); // 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; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; @@ -91,3 +89,31 @@ add_sub_assign_impl!(MulAssign, mul_assign, ClosedMul; const D; self: Scale, right: Scale; #[allow(clippy::suspicious_op_assign_impl)] { self.vector.component_mul_assign(&right.vector); }; ); + +// Point * Vector +add_sub_impl!(Mul, mul, ClosedMul; + (Const, U1), (Const, U1) -> (Const, U1) + const D; for; where; + self: &'a Point, right: &'b SVector, Output = Point; + #[allow(clippy::suspicious_arithmetic_impl)] { Point::from(self.coords.component_mul(&right)) }; + 'a, 'b); + +add_sub_impl!(Mul, mul, ClosedMul; + (Const, U1), (Const, U1) -> (Const, U1) + const D; for; where; + self: &'a Point, right: SVector, Output = Point; + #[allow(clippy::suspicious_arithmetic_impl)] { Point::from(self.coords.component_mul(&right)) }; + 'a); + +add_sub_impl!(Mul, mul, ClosedMul; + (Const, U1), (Const, U1) -> (Const, U1) + const D; for; where; + self: Point, right: &'b SVector, Output = Point; + #[allow(clippy::suspicious_arithmetic_impl)] { Point::from(self.coords.component_mul(&right)) }; + 'b); + +add_sub_impl!(Mul, mul, ClosedMul; + (Const, U1), (Const, U1) -> (Const, U1) + const D; for; where; + self: Point, right: SVector, Output = Point; + #[allow(clippy::suspicious_arithmetic_impl)] { Point::from(self.coords.component_mul(&right)) }; );