From f218186ec08f9c81a4dc2a5df605c4f8dfbee71d Mon Sep 17 00:00:00 2001 From: sebcrozet Date: Mon, 24 Sep 2018 21:31:54 +0200 Subject: [PATCH] Add Rotation * Unit --- src/geometry/rotation_ops.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/geometry/rotation_ops.rs b/src/geometry/rotation_ops.rs index c6f9e2e3..419830f2 100644 --- a/src/geometry/rotation_ops.rs +++ b/src/geometry/rotation_ops.rs @@ -10,6 +10,7 @@ * Matrix × Rotation * Matrix ÷ Rotation * Rotation × Point + * Rotation × Unit * * * Rotation ×= Rotation @@ -21,7 +22,7 @@ use num::{One, Zero}; use alga::general::{ClosedAdd, ClosedMul}; -use base::{DefaultAllocator, Matrix, MatrixMN, Scalar}; +use base::{DefaultAllocator, Matrix, MatrixMN, Scalar, Unit, Vector, VectorN}; use base::dimension::{Dim, DimName, U1}; use base::constraint::{AreMultipliable, ShapeConstraint}; use base::storage::Storage; @@ -118,6 +119,19 @@ md_impl_all!( [ref ref] => self.matrix() * right; ); +// Rotation × Unit +md_impl_all!( + Mul, mul; + (D, D), (D, U1) for D: DimName, S: Storage + where DefaultAllocator: Allocator + where ShapeConstraint: AreMultipliable; + self: Rotation, right: Unit>, Output = Unit>; + [val val] => Unit::new_unchecked(self.unwrap() * right.unwrap()); + [ref val] => Unit::new_unchecked(self.matrix() * right.unwrap()); + [val ref] => Unit::new_unchecked(self.unwrap() * right.as_ref()); + [ref ref] => Unit::new_unchecked(self.matrix() * right.as_ref()); +); + // Rotation ×= Rotation // FIXME: try not to call `inverse()` explicitly.