2018-02-02 19:26:35 +08:00
|
|
|
|
use num::{One, Zero};
|
|
|
|
|
use std::ops::{Div, DivAssign, Index, IndexMut, Mul, MulAssign};
|
2016-12-05 05:44:42 +08:00
|
|
|
|
|
2020-03-21 19:16:46 +08:00
|
|
|
|
use simba::scalar::{ClosedAdd, ClosedMul, RealField, SubsetOf};
|
2016-12-05 05:44:42 +08:00
|
|
|
|
|
2019-03-23 21:29:07 +08:00
|
|
|
|
use crate::base::allocator::Allocator;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
use crate::base::dimension::{DimNameAdd, DimNameSum, U1, U4};
|
|
|
|
|
use crate::base::{CVectorN, Const, DefaultAllocator, MatrixN, Scalar};
|
2016-12-05 05:44:42 +08:00
|
|
|
|
|
2019-03-23 21:29:07 +08:00
|
|
|
|
use crate::geometry::{
|
2018-10-22 13:00:10 +08:00
|
|
|
|
Isometry, Point, Rotation, Similarity, SubTCategoryOf, SuperTCategoryOf, TAffine, TCategory,
|
|
|
|
|
TCategoryMul, TGeneral, TProjective, Transform, Translation, UnitQuaternion,
|
|
|
|
|
};
|
2016-12-05 05:44:42 +08:00
|
|
|
|
|
2017-02-13 01:17:09 +08:00
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* In the following, we provide:
|
|
|
|
|
* =========================
|
|
|
|
|
*
|
|
|
|
|
* Index<(usize, usize)>
|
|
|
|
|
* IndexMut<(usize, usize)> (where TCategory == TGeneral)
|
|
|
|
|
*
|
|
|
|
|
* (Operators)
|
|
|
|
|
*
|
2017-08-03 01:37:44 +08:00
|
|
|
|
* Transform × Isometry
|
|
|
|
|
* Transform × Rotation
|
|
|
|
|
* Transform × Similarity
|
|
|
|
|
* Transform × Transform
|
|
|
|
|
* Transform × UnitQuaternion
|
2020-11-15 23:57:49 +08:00
|
|
|
|
* TODO: Transform × UnitComplex
|
2017-08-03 01:37:44 +08:00
|
|
|
|
* Transform × Translation
|
|
|
|
|
* Transform × Vector
|
|
|
|
|
* Transform × Point
|
2017-02-13 01:17:09 +08:00
|
|
|
|
*
|
2017-08-03 01:37:44 +08:00
|
|
|
|
* Isometry × Transform
|
|
|
|
|
* Rotation × Transform
|
|
|
|
|
* Similarity × Transform
|
|
|
|
|
* Translation × Transform
|
|
|
|
|
* UnitQuaternion × Transform
|
2020-11-15 23:57:49 +08:00
|
|
|
|
* TODO: UnitComplex × Transform
|
2017-02-13 01:17:09 +08:00
|
|
|
|
*
|
2020-11-15 23:57:49 +08:00
|
|
|
|
* TODO: Transform ÷ Isometry
|
2017-08-03 01:37:44 +08:00
|
|
|
|
* Transform ÷ Rotation
|
2020-11-15 23:57:49 +08:00
|
|
|
|
* TODO: Transform ÷ Similarity
|
2017-08-03 01:37:44 +08:00
|
|
|
|
* Transform ÷ Transform
|
|
|
|
|
* Transform ÷ UnitQuaternion
|
|
|
|
|
* Transform ÷ Translation
|
2017-02-13 01:17:09 +08:00
|
|
|
|
*
|
2020-11-15 23:57:49 +08:00
|
|
|
|
* TODO: Isometry ÷ Transform
|
2017-08-03 01:37:44 +08:00
|
|
|
|
* Rotation ÷ Transform
|
2020-11-15 23:57:49 +08:00
|
|
|
|
* TODO: Similarity ÷ Transform
|
2017-08-03 01:37:44 +08:00
|
|
|
|
* Translation ÷ Transform
|
|
|
|
|
* UnitQuaternion ÷ Transform
|
2020-11-15 23:57:49 +08:00
|
|
|
|
* TODO: UnitComplex ÷ Transform
|
2017-02-13 01:17:09 +08:00
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* (Assignment Operators)
|
|
|
|
|
*
|
|
|
|
|
*
|
2017-08-03 01:37:44 +08:00
|
|
|
|
* Transform ×= Transform
|
|
|
|
|
* Transform ×= Similarity
|
|
|
|
|
* Transform ×= Isometry
|
|
|
|
|
* Transform ×= Rotation
|
|
|
|
|
* Transform ×= UnitQuaternion
|
2020-11-15 23:57:49 +08:00
|
|
|
|
* TODO: Transform ×= UnitComplex
|
2017-08-03 01:37:44 +08:00
|
|
|
|
* Transform ×= Translation
|
2017-02-13 01:17:09 +08:00
|
|
|
|
*
|
2017-08-03 01:37:44 +08:00
|
|
|
|
* Transform ÷= Transform
|
2020-11-15 23:57:49 +08:00
|
|
|
|
* TODO: Transform ÷= Similarity
|
|
|
|
|
* TODO: Transform ÷= Isometry
|
2017-08-03 01:37:44 +08:00
|
|
|
|
* Transform ÷= Rotation
|
|
|
|
|
* Transform ÷= UnitQuaternion
|
2020-11-15 23:57:49 +08:00
|
|
|
|
* TODO: Transform ÷= UnitComplex
|
2017-02-13 01:17:09 +08:00
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2016-12-05 05:44:42 +08:00
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* Indexing.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2021-04-07 20:29:20 +08:00
|
|
|
|
impl<N: RealField, C: TCategory, const D: usize> Index<(usize, usize)> for Transform<N, C, D>
|
2018-02-02 19:26:35 +08:00
|
|
|
|
where
|
2021-04-07 20:29:20 +08:00
|
|
|
|
Const<D>: DimNameAdd<U1>,
|
|
|
|
|
DefaultAllocator: Allocator<N, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
2018-02-02 19:26:35 +08:00
|
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
|
type Output = N;
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
fn index(&self, ij: (usize, usize)) -> &N {
|
|
|
|
|
self.matrix().index(ij)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Only general transformations are mutably indexable.
|
2021-04-07 20:29:20 +08:00
|
|
|
|
impl<N: RealField, const D: usize> IndexMut<(usize, usize)> for Transform<N, TGeneral, D>
|
2018-02-02 19:26:35 +08:00
|
|
|
|
where
|
2021-04-07 20:29:20 +08:00
|
|
|
|
Const<D>: DimNameAdd<U1>,
|
|
|
|
|
DefaultAllocator: Allocator<N, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
2018-02-02 19:26:35 +08:00
|
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
|
#[inline]
|
|
|
|
|
fn index_mut(&mut self, ij: (usize, usize)) -> &mut N {
|
|
|
|
|
self.matrix_mut().index_mut(ij)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform × Vector
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategory;
|
|
|
|
|
self: Transform<N, C, D>, rhs: CVectorN<N, D>, Output = CVectorN<N, D>;
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[val val] => &self * &rhs;
|
|
|
|
|
[ref val] => self * &rhs;
|
|
|
|
|
[val ref] => &self * rhs;
|
|
|
|
|
[ref ref] => {
|
2021-04-08 17:53:01 +08:00
|
|
|
|
let transform = self.matrix().fixed_slice::<Const<D>, Const<D>>(0, 0);
|
2016-12-05 05:44:42 +08:00
|
|
|
|
|
|
|
|
|
if C::has_normalizer() {
|
2021-04-08 17:53:01 +08:00
|
|
|
|
let normalizer = self.matrix().fixed_slice::<U1, Const<D>>(D, 0);
|
2016-12-05 05:44:42 +08:00
|
|
|
|
let n = normalizer.tr_dot(&rhs);
|
|
|
|
|
|
|
|
|
|
if !n.is_zero() {
|
|
|
|
|
return transform * (rhs / n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transform * rhs
|
|
|
|
|
};
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform × Point
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategory;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Point<N, D>, Output = Point<N, D>;
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[val val] => &self * &rhs;
|
|
|
|
|
[ref val] => self * &rhs;
|
|
|
|
|
[val ref] => &self * rhs;
|
|
|
|
|
[ref ref] => {
|
2021-04-08 17:53:01 +08:00
|
|
|
|
let transform = self.matrix().fixed_slice::<Const<D>, Const<D>>(0, 0);
|
|
|
|
|
let translation = self.matrix().fixed_slice::<Const<D>, U1>(0, D);
|
2016-12-05 05:44:42 +08:00
|
|
|
|
|
|
|
|
|
if C::has_normalizer() {
|
2021-04-08 17:53:01 +08:00
|
|
|
|
let normalizer = self.matrix().fixed_slice::<U1, Const<D>>(D, 0);
|
2020-10-26 01:23:24 +08:00
|
|
|
|
#[allow(clippy::suspicious_arithmetic_impl)]
|
2021-04-08 17:53:01 +08:00
|
|
|
|
let n = normalizer.tr_dot(&rhs.coords) + unsafe { *self.matrix().get_unchecked((D, D)) };
|
2016-12-05 05:44:42 +08:00
|
|
|
|
|
|
|
|
|
if !n.is_zero() {
|
2018-09-21 02:01:48 +08:00
|
|
|
|
return (transform * rhs + translation) / n;
|
2016-12-05 05:44:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transform * rhs + translation
|
|
|
|
|
};
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform × Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>)
|
|
|
|
|
const D;
|
|
|
|
|
for CA, CB;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, CA: TCategoryMul<CB>, CB: TCategory;
|
|
|
|
|
self: Transform<N, CA, D>, rhs: Transform<N, CB, D>, Output = Transform<N, CA::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.into_inner());
|
|
|
|
|
[ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.into_inner());
|
|
|
|
|
[val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.matrix());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.matrix());
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform × Rotation
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, Const<D>)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Rotation<N, D>, Output = Transform<N, C::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Rotation × Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(Const<D>, Const<D>), (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Rotation<N, D>, rhs: Transform<N, C, D>, Output = Transform<N, C::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[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());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
[ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform × UnitQuaternion
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(U4, U4), (U4, U1)
|
|
|
|
|
const;
|
|
|
|
|
for C;
|
|
|
|
|
where C: TCategoryMul<TAffine>;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, 3>, rhs: UnitQuaternion<N>, Output = Transform<N, C::Representative, 3>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// UnitQuaternion × Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(U4, U1), (U4, U4)
|
|
|
|
|
const;
|
|
|
|
|
for C;
|
|
|
|
|
where C: TCategoryMul<TAffine>;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: UnitQuaternion<N>, rhs: Transform<N, C, 3>, Output = Transform<N, C::Representative, 3>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[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());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
[ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform × Isometry
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
const D;
|
|
|
|
|
for C, R;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<Const<D>, U1>> >;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Isometry<N, R, D>, Output = Transform<N, C::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Isometry × Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(Const<D>, U1), (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>)
|
|
|
|
|
const D;
|
|
|
|
|
for C, R;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<Const<D>, U1>> >;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Isometry<N, R, D>, rhs: Transform<N, C, D>, Output = Transform<N, C::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[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());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
[ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform × Similarity
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
const D;
|
|
|
|
|
for C, R;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<Const<D>, U1>> >;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Similarity<N, R, D>, Output = Transform<N, C::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Similarity × Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(Const<D>, U1), (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>)
|
|
|
|
|
const D;
|
|
|
|
|
for C, R;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<Const<D>, U1>> >;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Similarity<N, R, D>, rhs: Transform<N, C, D>, Output = Transform<N, C::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[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());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
[ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
2020-11-15 23:57:49 +08:00
|
|
|
|
* TODO: don't explicitly build the homogeneous translation matrix.
|
2016-12-05 05:44:42 +08:00
|
|
|
|
* Directly apply the translation, just as in `Matrix::{append,prepend}_translation`. This has not
|
|
|
|
|
* been done yet because of the `DimNameDiff` requirement (which is not automatically deduced from
|
|
|
|
|
* `DimNameAdd` requirement).
|
|
|
|
|
*
|
|
|
|
|
*/
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform × Translation
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Translation<N, D>, Output = Transform<N, C::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Translation × Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Mul, mul where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(Const<D>, U1), (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Translation<N, D>, rhs: Transform<N, C, D>, Output = Transform<N, C::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[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());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
[ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ÷ Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Div, div where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>)
|
|
|
|
|
const D;
|
|
|
|
|
for CA, CB;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, CA: TCategoryMul<CB>, CB: SubTCategoryOf<TProjective>;
|
|
|
|
|
self: Transform<N, CA, D>, rhs: Transform<N, CB, D>, Output = Transform<N, CA::Representative, D>;
|
2020-10-26 01:23:24 +08:00
|
|
|
|
[val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
|
|
|
|
[ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
|
|
|
|
[val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.clone().inverse() };
|
|
|
|
|
[ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.clone().inverse() };
|
2016-12-05 05:44:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ÷ Rotation
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Div, div where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, Const<D>)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Rotation<N, D>, Output = Transform<N, C::Representative, D>;
|
2020-10-26 01:23:24 +08:00
|
|
|
|
[val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
|
|
|
|
[ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
|
|
|
|
[val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
|
|
|
|
[ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
2016-12-05 05:44:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Rotation ÷ Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Div, div where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(Const<D>, Const<D>), (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Rotation<N, D>, rhs: Transform<N, C, D>, Output = Transform<N, C::Representative, D>;
|
2020-10-26 01:23:24 +08:00
|
|
|
|
[val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
|
|
|
|
|
[ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
|
|
|
|
|
[val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
|
|
|
|
|
[ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
|
2016-12-05 05:44:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ÷ UnitQuaternion
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Div, div where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(U4, U4), (U4, U1)
|
|
|
|
|
const;
|
|
|
|
|
for C;
|
|
|
|
|
where C: TCategoryMul<TAffine>;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, 3>, rhs: UnitQuaternion<N>, Output = Transform<N, C::Representative, 3>;
|
2020-10-26 01:23:24 +08:00
|
|
|
|
[val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
|
|
|
|
[ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
|
|
|
|
[val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
|
|
|
|
[ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
2016-12-05 05:44:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// UnitQuaternion ÷ Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Div, div where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(U4, U1), (U4, U4)
|
|
|
|
|
const;
|
|
|
|
|
for C;
|
|
|
|
|
where C: TCategoryMul<TAffine>;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: UnitQuaternion<N>, rhs: Transform<N, C, 3>, Output = Transform<N, C::Representative, 3>;
|
2020-10-26 01:23:24 +08:00
|
|
|
|
[val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
|
|
|
|
|
[ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
|
|
|
|
|
[val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
|
|
|
|
|
[ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
|
2016-12-05 05:44:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// // Transform ÷ Isometry
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
// Div, div where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
// (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
// for Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<Const<D>, U1>> >
|
|
|
|
|
// where SB::Alloc: Allocator<N, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1> >;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
// self: Transform<N, C, D>, rhs: Isometry<N, R, D>, Output = Transform<N, C::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
// [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.inverse().to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.inverse().to_homogeneous());
|
2018-12-10 04:24:08 +08:00
|
|
|
|
// [val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.inverse().to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// [ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.inverse().to_homogeneous());
|
|
|
|
|
// );
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// // Isometry ÷ Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
// Div, div where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
// (Const<D>, U1), (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>)
|
|
|
|
|
// for Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<Const<D>, U1>> >
|
|
|
|
|
// where SA::Alloc: Allocator<N, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1> >;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
// self: Isometry<N, R, D>, rhs: Transform<N, C, D>, Output = Transform<N, C::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
// [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());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// [val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
// [ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
// );
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// // Transform ÷ Similarity
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
// Div, div where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
// (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
// for Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<Const<D>, U1>> >
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// where SB::Alloc: Allocator<N, D, D >
|
2021-04-08 17:53:01 +08:00
|
|
|
|
// where SB::Alloc: Allocator<N, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1> >;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
// self: Transform<N, C, D>, rhs: Similarity<N, R, D>, Output = Transform<N, C::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
// [val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// [ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
2018-12-10 04:24:08 +08:00
|
|
|
|
// [val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// [ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
|
|
|
|
// );
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// // Similarity ÷ Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
// Div, div where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
// (Const<D>, U1), (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>)
|
|
|
|
|
// for Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>, R: SubsetOf<MatrixN<N, DimNameSum<Const<D>, U1>> >
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// where SA::Alloc: Allocator<N, D, D >
|
2021-04-08 17:53:01 +08:00
|
|
|
|
// where SA::Alloc: Allocator<N, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1> >;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
// self: Similarity<N, R, D>, rhs: Transform<N, C, D>, Output = Transform<N, C::Representative, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
// [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());
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// [val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
// [ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
|
|
|
|
// );
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ÷ Translation
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Div, div where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Translation<N, D>, Output = Transform<N, C::Representative, D>;
|
2020-10-26 01:23:24 +08:00
|
|
|
|
[val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
|
|
|
|
[ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
|
|
|
|
[val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
|
|
|
|
[ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self * rhs.inverse() };
|
2016-12-05 05:44:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Translation ÷ Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
Div, div where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(Const<D>, U1), (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategoryMul<TAffine>;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Translation<N, D>, rhs: Transform<N, C, D>, Output = Transform<N, C::Representative, D>;
|
2020-10-26 01:23:24 +08:00
|
|
|
|
[val val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
|
|
|
|
|
[ref val] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
|
|
|
|
|
[val ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
|
|
|
|
|
[ref ref] => #[allow(clippy::suspicious_arithmetic_impl)] { self.inverse() * rhs };
|
2016-12-05 05:44:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ×= Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_assign_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
MulAssign, mul_assign where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>)
|
|
|
|
|
const D;
|
|
|
|
|
for CA, CB;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, CA: TCategory, CB: SubTCategoryOf<CA>;
|
|
|
|
|
self: Transform<N, CA, D>, rhs: Transform<N, CB, D>;
|
2018-12-10 04:24:08 +08:00
|
|
|
|
[val] => *self.matrix_mut_unchecked() *= rhs.into_inner();
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[ref] => *self.matrix_mut_unchecked() *= rhs.matrix();
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ×= Similarity
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_assign_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
MulAssign, mul_assign where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
const D;
|
|
|
|
|
for C, R;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategory, R: SubsetOf<MatrixN<N, DimNameSum<Const<D>, U1>> >;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Similarity<N, R, D>;
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
|
|
|
|
[ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ×= Isometry
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_assign_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
MulAssign, mul_assign where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
const D;
|
|
|
|
|
for C, R;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategory, R: SubsetOf<MatrixN<N, DimNameSum<Const<D>, U1>> >;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Isometry<N, R, D>;
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
|
|
|
|
[ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
2020-11-15 23:57:49 +08:00
|
|
|
|
* TODO: don't explicitly build the homogeneous translation matrix.
|
2016-12-05 05:44:42 +08:00
|
|
|
|
* Directly apply the translation, just as in `Matrix::{append,prepend}_translation`. This has not
|
|
|
|
|
* been done yet because of the `DimNameDiff` requirement (which is not automatically deduced from
|
|
|
|
|
* `DimNameAdd` requirement).
|
|
|
|
|
*
|
|
|
|
|
*/
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ×= Translation
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_assign_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
MulAssign, mul_assign where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategory;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Translation<N, D>;
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
|
|
|
|
[ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ×= Rotation
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_assign_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
MulAssign, mul_assign where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, Const<D>)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategory;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Rotation<N, D>;
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
|
|
|
|
[ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ×= UnitQuaternion
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_assign_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
MulAssign, mul_assign where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(U4, U4), (U4, U1)
|
|
|
|
|
const;
|
|
|
|
|
for C;
|
|
|
|
|
where C: TCategory;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, 3>, rhs: UnitQuaternion<N>;
|
2016-12-05 05:44:42 +08:00
|
|
|
|
[val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
|
|
|
|
[ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ÷= Transform
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_assign_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
DivAssign, div_assign where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>)
|
|
|
|
|
const D;
|
|
|
|
|
for CA, CB;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, CA: SuperTCategoryOf<CB>, CB: SubTCategoryOf<TProjective>;
|
|
|
|
|
self: Transform<N, CA, D>, rhs: Transform<N, CB, D>;
|
2020-10-26 19:44:53 +08:00
|
|
|
|
[val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
|
|
|
|
[ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.clone().inverse() };
|
2016-12-05 05:44:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// // Transform ÷= Similarity
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// md_assign_impl_all!(
|
|
|
|
|
// DivAssign, div_assign;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
// (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
// for Const<D>: DimNameAdd<U1>, C: TCategory, R: SubsetOf<MatrixN<N, DimNameSum<Const<D>, U1>> >;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
// self: Transform<N, C, D>, rhs: Similarity<N, R, D>;
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// [val] => *self *= rhs.inverse();
|
|
|
|
|
// [ref] => *self *= rhs.inverse();
|
|
|
|
|
// );
|
2018-02-02 19:26:35 +08:00
|
|
|
|
//
|
|
|
|
|
//
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// // Transform ÷= Isometry
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// md_assign_impl_all!(
|
|
|
|
|
// DivAssign, div_assign;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
// (DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
// for Const<D>: DimNameAdd<U1>, C: TCategory, R: SubsetOf<MatrixN<N, DimNameSum<Const<D>, U1>> >;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
// self: Transform<N, C, D>, rhs: Isometry<N, R, D>;
|
2016-12-05 05:44:42 +08:00
|
|
|
|
// [val] => *self *= rhs.inverse();
|
|
|
|
|
// [ref] => *self *= rhs.inverse();
|
|
|
|
|
// );
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ÷= Translation
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_assign_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
DivAssign, div_assign where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, U1)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategory;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Translation<N, D>;
|
2020-10-26 19:44:53 +08:00
|
|
|
|
[val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
|
|
|
|
[ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
2016-12-05 05:44:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ÷= Rotation
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_assign_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
DivAssign, div_assign where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>), (Const<D>, Const<D>)
|
|
|
|
|
const D;
|
|
|
|
|
for C;
|
|
|
|
|
where Const<D>: DimNameAdd<U1>, C: TCategory;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, D>, rhs: Rotation<N, D>;
|
2020-10-26 19:44:53 +08:00
|
|
|
|
[val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
|
|
|
|
[ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
2016-12-05 05:44:42 +08:00
|
|
|
|
);
|
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
|
// Transform ÷= UnitQuaternion
|
2016-12-05 05:44:42 +08:00
|
|
|
|
md_assign_impl_all!(
|
2019-03-25 18:21:41 +08:00
|
|
|
|
DivAssign, div_assign where N: RealField;
|
2021-04-08 17:53:01 +08:00
|
|
|
|
(U4, U4), (U4, U1)
|
|
|
|
|
const;
|
|
|
|
|
for C;
|
|
|
|
|
where C: TCategory;
|
2021-04-07 20:29:20 +08:00
|
|
|
|
self: Transform<N, C, 3>, rhs: UnitQuaternion<N>;
|
2020-10-26 19:44:53 +08:00
|
|
|
|
[val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
|
|
|
|
[ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
2016-12-05 05:44:42 +08:00
|
|
|
|
);
|