From b1775ee747df4f2243b59c13b17a9af1fa46c197 Mon Sep 17 00:00:00 2001 From: CAD97 Date: Wed, 14 Jul 2021 23:52:38 -0500 Subject: [PATCH] =?UTF-8?q?Add=20Transform=20=C3=97=20UnitComplex=20&=20fr?= =?UTF-8?q?iends?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/geometry/transform_ops.rs | 62 ++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/src/geometry/transform_ops.rs b/src/geometry/transform_ops.rs index c4ec5cfc..94ef4ab3 100644 --- a/src/geometry/transform_ops.rs +++ b/src/geometry/transform_ops.rs @@ -12,7 +12,7 @@ use crate::base::{Const, DefaultAllocator, OMatrix, SVector, Scalar}; use crate::geometry::{ Isometry, Point, Rotation, Similarity, SubTCategoryOf, SuperTCategoryOf, TAffine, TCategory, - TCategoryMul, TGeneral, TProjective, Transform, Translation, UnitQuaternion, + TCategoryMul, TGeneral, TProjective, Transform, Translation, UnitComplex, UnitQuaternion, }; /* @@ -30,7 +30,7 @@ use crate::geometry::{ * Transform × Similarity * Transform × Transform * Transform × UnitQuaternion - * TODO: Transform × UnitComplex + * Transform × UnitComplex * Transform × Translation * Transform × Vector * Transform × Point @@ -40,7 +40,7 @@ use crate::geometry::{ * Similarity × Transform * Translation × Transform * UnitQuaternion × Transform - * TODO: UnitComplex × Transform + * UnitComplex × Transform * * TODO: Transform ÷ Isometry * Transform ÷ Rotation @@ -65,7 +65,7 @@ use crate::geometry::{ * Transform ×= Isometry * Transform ×= Rotation * Transform ×= UnitQuaternion - * TODO: Transform ×= UnitComplex + * Transform ×= UnitComplex * Transform ×= Translation * * Transform ÷= Transform @@ -73,7 +73,7 @@ use crate::geometry::{ * TODO: Transform ÷= Isometry * Transform ÷= Rotation * Transform ÷= UnitQuaternion - * TODO: Transform ÷= UnitComplex + * Transform ÷= UnitComplex * */ @@ -225,6 +225,20 @@ md_impl_all!( [ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); ); +// Transform × UnitComplex +md_impl_all!( + Mul, mul where T: RealField; + (U3, U3), (U2, U1) + const; + for C; + where C: TCategoryMul; + self: Transform, rhs: UnitComplex, Output = Transform; + [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); + [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); + [val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous()); + [ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous()); +); + // UnitQuaternion × Transform md_impl_all!( Mul, mul where T: RealField; @@ -239,6 +253,20 @@ md_impl_all!( [ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); ); +// UnitComplex × Transform +md_impl_all!( + Mul, mul where T: RealField; + (U2, U1), (U3, U3) + const; + for C; + where C: TCategoryMul; + self: UnitComplex, rhs: Transform, Output = Transform; + [val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); + [ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner()); + [val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); + [ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); +); + // Transform × Isometry md_impl_all!( Mul, mul where T: RealField; @@ -579,6 +607,18 @@ md_assign_impl_all!( [ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); ); +// Transform ×= UnitComplex +md_assign_impl_all!( + MulAssign, mul_assign where T: RealField; + (U3, U3), (U2, U1) + const; + for C; + where C: TCategory; + self: Transform, rhs: UnitComplex; + [val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); + [ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); +); + // Transform ÷= Transform md_assign_impl_all!( DivAssign, div_assign where T: RealField; @@ -650,3 +690,15 @@ md_assign_impl_all!( [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; ); + +// Transform ÷= UnitComplex +md_assign_impl_all!( + DivAssign, div_assign where T: RealField; + (U3, U3), (U2, U1) + const; + for C; + where C: TCategory; + self: Transform, rhs: UnitComplex; + [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; + [ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; +);