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

View File

@ -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<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
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<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
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<T, C, 2>, rhs: UnitComplex<T>;
[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<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() };
);