Merge pull request #948 from CAD97/ops-transform-complex

Add Transform × UnitComplex & friends
This commit is contained in:
Sébastien Crozet 2021-07-27 15:22:53 +02:00 committed by GitHub
commit 2a80e96766
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 57 additions and 5 deletions

View File

@ -12,7 +12,7 @@ use crate::base::{Const, DefaultAllocator, OMatrix, SVector, Scalar};
use crate::geometry::{ use crate::geometry::{
Isometry, Point, Rotation, Similarity, SubTCategoryOf, SuperTCategoryOf, TAffine, TCategory, 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 × Similarity
* Transform × Transform * Transform × Transform
* Transform × UnitQuaternion * Transform × UnitQuaternion
* TODO: Transform × UnitComplex * Transform × UnitComplex
* Transform × Translation * Transform × Translation
* Transform × Vector * Transform × Vector
* Transform × Point * Transform × Point
@ -40,7 +40,7 @@ use crate::geometry::{
* Similarity × Transform * Similarity × Transform
* Translation × Transform * Translation × Transform
* UnitQuaternion × Transform * UnitQuaternion × Transform
* TODO: UnitComplex × Transform * UnitComplex × Transform
* *
* TODO: Transform ÷ Isometry * TODO: Transform ÷ Isometry
* Transform ÷ Rotation * Transform ÷ Rotation
@ -65,7 +65,7 @@ use crate::geometry::{
* Transform ×= Isometry * Transform ×= Isometry
* Transform ×= Rotation * Transform ×= Rotation
* Transform ×= UnitQuaternion * Transform ×= UnitQuaternion
* TODO: Transform ×= UnitComplex * Transform ×= UnitComplex
* Transform ×= Translation * Transform ×= Translation
* *
* Transform ÷= Transform * Transform ÷= Transform
@ -73,7 +73,7 @@ use crate::geometry::{
* TODO: Transform ÷= Isometry * TODO: Transform ÷= Isometry
* Transform ÷= Rotation * Transform ÷= Rotation
* Transform ÷= UnitQuaternion * 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()); [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<TAffine>;
self: Transform<T, C, 2>, rhs: UnitComplex<T>, Output = Transform<T, C::Representative, 2>;
[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 // UnitQuaternion × Transform
md_impl_all!( md_impl_all!(
Mul, mul where T: RealField; Mul, mul where T: RealField;
@ -239,6 +253,20 @@ md_impl_all!(
[ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix()); [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<TAffine>;
self: UnitComplex<T>, rhs: Transform<T, C, 2>, Output = Transform<T, C::Representative, 2>;
[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 // Transform × Isometry
md_impl_all!( md_impl_all!(
Mul, mul where T: RealField; Mul, mul where T: RealField;
@ -579,6 +607,18 @@ md_assign_impl_all!(
[ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous(); [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<T, C, 2>, rhs: UnitComplex<T>;
[val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
[ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
);
// Transform ÷= Transform // Transform ÷= Transform
md_assign_impl_all!( md_assign_impl_all!(
DivAssign, div_assign where T: RealField; DivAssign, div_assign where T: RealField;
@ -650,3 +690,15 @@ md_assign_impl_all!(
[val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() }; [val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
[ref] => #[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<T, C, 2>, rhs: UnitComplex<T>;
[val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
[ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
);