From 1341801c56bb5bfb9412798c99387d3c63a2ac25 Mon Sep 17 00:00:00 2001 From: Yuri Edward Date: Tue, 19 Oct 2021 16:33:12 +0200 Subject: [PATCH] Added scale * scalar + Cleanup scale_ops --- src/geometry/scale_ops.rs | 40 +++++++-------------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/src/geometry/scale_ops.rs b/src/geometry/scale_ops.rs index 4d8b5f41..6a55cf40 100644 --- a/src/geometry/scale_ops.rs +++ b/src/geometry/scale_ops.rs @@ -36,34 +36,19 @@ add_sub_impl!(Mul, mul, ClosedMul; self: Scale, right: Scale, Output = Scale; #[allow(clippy::suspicious_arithmetic_impl)] { Scale::from(self.vector.component_mul(&right.vector)) }; ); -// Scale ÷ Scale -// TODO: instead of calling inverse explicitly, could we just add a `mul_tr` or `mul_inv` method? -/*add_sub_impl!(Div, div, ClosedSub; +// Scale × scalar +add_sub_impl!(Mul, mul, ClosedMul; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; - self: &'a Scale, right: &'b Scale, Output = Scale; - #[allow(clippy::suspicious_arithmetic_impl)] { todo!(); }; - 'a, 'b); - -add_sub_impl!(Div, div, ClosedSub; - (Const, U1), (Const, U1) -> (Const, U1) - const D; for; where; - self: &'a Scale, right: Scale, Output = Scale; - #[allow(clippy::suspicious_arithmetic_impl)] { todo!(); }; + self: &'a Scale, right: T, Output = Scale; + #[allow(clippy::suspicious_arithmetic_impl)] { Scale::from(&self.vector * right) }; 'a); -add_sub_impl!(Div, div, ClosedSub; +add_sub_impl!(Mul, mul, ClosedMul; (Const, U1), (Const, U1) -> (Const, U1) const D; for; where; - self: Scale, right: &'b Scale, Output = Scale; - #[allow(clippy::suspicious_arithmetic_impl)] { todo!(); }; - 'b); - -add_sub_impl!(Div, div, ClosedSub; - (Const, U1), (Const, U1) -> (Const, U1) - const D; for; where; - self: Scale, right: Scale, Output = Scale; - #[allow(clippy::suspicious_arithmetic_impl)] { todo!(); }; );*/ + self: Scale, right: T, Output = Scale; + #[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 @@ -106,14 +91,3 @@ 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); }; ); - -/*add_sub_assign_impl!(DivAssign, div_assign, ClosedSub; - const D; - self: Scale, right: &'b Scale; - #[allow(clippy::suspicious_op_assign_impl)] { todo!(); }; - 'b); - -add_sub_assign_impl!(DivAssign, div_assign, ClosedSub; - const D; - self: Scale, right: Scale; - #[allow(clippy::suspicious_op_assign_impl)] { todo!(); }; );*/