2020-03-21 19:16:46 +08:00
|
|
|
use simba::scalar::{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-07 20:29:20 +08:00
|
|
|
use crate::base::dimension::{DimNameAdd, DimNameSum, U1};
|
2021-04-11 17:00:38 +08:00
|
|
|
use crate::base::{Const, DefaultAllocator, OMatrix};
|
2016-12-05 05:44:42 +08:00
|
|
|
|
2019-03-23 21:29:07 +08:00
|
|
|
use crate::geometry::{SuperTCategoryOf, TCategory, Transform};
|
2016-12-05 05:44:42 +08:00
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T1, T2, C1, C2, const D: usize> SubsetOf<Transform<T2, C2, D>> for Transform<T1, C1, D>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T1: RealField + SubsetOf<T2>,
|
|
|
|
T2: RealField,
|
2018-02-02 19:26:35 +08:00
|
|
|
C1: TCategory,
|
|
|
|
C2: SuperTCategoryOf<C1>,
|
2021-04-07 20:29:20 +08:00
|
|
|
Const<D>: DimNameAdd<U1>,
|
2021-04-11 17:00:38 +08:00
|
|
|
DefaultAllocator: Allocator<T1, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>
|
|
|
|
+ Allocator<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
|
|
|
T1::Epsilon: Copy,
|
|
|
|
T2::Epsilon: Copy,
|
2018-02-02 19:26:35 +08:00
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn to_superset(&self) -> Transform<T2, C2, D> {
|
2017-08-03 01:37:44 +08:00
|
|
|
Transform::from_matrix_unchecked(self.to_homogeneous().to_superset())
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn is_in_subset(t: &Transform<T2, C2, D>) -> bool {
|
2016-12-05 05:44:42 +08:00
|
|
|
<Self as SubsetOf<_>>::is_in_subset(t.matrix())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from_superset_unchecked(t: &Transform<T2, C2, D>) -> Self {
|
2016-12-05 05:44:42 +08:00
|
|
|
Self::from_superset_unchecked(t.matrix())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T1, T2, C, const D: usize>
|
|
|
|
SubsetOf<OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>>
|
|
|
|
for Transform<T1, C, D>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2021-04-11 17:00:38 +08:00
|
|
|
T1: RealField + SubsetOf<T2>,
|
|
|
|
T2: RealField,
|
2018-02-02 19:26:35 +08:00
|
|
|
C: TCategory,
|
2021-04-07 20:29:20 +08:00
|
|
|
Const<D>: DimNameAdd<U1>,
|
2021-04-11 17:00:38 +08:00
|
|
|
DefaultAllocator: Allocator<T1, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>
|
|
|
|
+ Allocator<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
|
|
|
T1::Epsilon: Copy,
|
|
|
|
T2::Epsilon: Copy,
|
2018-02-02 19:26:35 +08:00
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn to_superset(&self) -> OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>> {
|
2016-12-05 05:44:42 +08:00
|
|
|
self.matrix().to_superset()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn is_in_subset(m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>) -> bool {
|
2016-12-05 05:44:42 +08:00
|
|
|
C::check_homogeneous_invariants(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from_superset_unchecked(
|
|
|
|
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
|
|
|
) -> Self {
|
2019-03-23 21:29:07 +08:00
|
|
|
Self::from_matrix_unchecked(crate::convert_ref_unchecked(m))
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
}
|
2018-10-13 16:25:34 +08:00
|
|
|
|
2021-04-11 17:00:38 +08:00
|
|
|
impl<T: RealField, C, const D: usize> From<Transform<T, C, D>>
|
|
|
|
for OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>
|
2018-10-13 16:25:34 +08:00
|
|
|
where
|
2021-04-07 20:29:20 +08:00
|
|
|
Const<D>: DimNameAdd<U1>,
|
2018-10-13 16:25:34 +08:00
|
|
|
C: TCategory,
|
2021-04-11 17:00:38 +08:00
|
|
|
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
2018-10-13 16:25:34 +08:00
|
|
|
{
|
|
|
|
#[inline]
|
2021-04-11 17:00:38 +08:00
|
|
|
fn from(t: Transform<T, C, D>) -> Self {
|
2018-10-13 16:25:34 +08:00
|
|
|
t.to_homogeneous()
|
|
|
|
}
|
|
|
|
}
|