2019-03-25 18:21:41 +08:00
|
|
|
use alga::general::{RealField, SubsetOf};
|
2016-12-05 05:44:42 +08:00
|
|
|
|
2019-03-23 21:29:07 +08:00
|
|
|
use crate::base::allocator::Allocator;
|
|
|
|
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
|
|
|
|
use crate::base::{DefaultAllocator, MatrixN};
|
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
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
impl<N1, N2, D: DimName, C1, C2> SubsetOf<Transform<N2, D, C2>> for Transform<N1, D, C1>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2019-03-25 18:21:41 +08:00
|
|
|
N1: RealField + SubsetOf<N2>,
|
|
|
|
N2: RealField,
|
2018-02-02 19:26:35 +08:00
|
|
|
C1: TCategory,
|
|
|
|
C2: SuperTCategoryOf<C1>,
|
|
|
|
D: DimNameAdd<U1>,
|
|
|
|
DefaultAllocator: Allocator<N1, DimNameSum<D, U1>, DimNameSum<D, U1>>
|
|
|
|
+ Allocator<N2, DimNameSum<D, U1>, DimNameSum<D, U1>>,
|
|
|
|
N1::Epsilon: Copy,
|
|
|
|
N2::Epsilon: Copy,
|
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn to_superset(&self) -> Transform<N2, D, C2> {
|
|
|
|
Transform::from_matrix_unchecked(self.to_homogeneous().to_superset())
|
2016-12-05 05:44:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn is_in_subset(t: &Transform<N2, D, C2>) -> bool {
|
2016-12-05 05:44:42 +08:00
|
|
|
<Self as SubsetOf<_>>::is_in_subset(t.matrix())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
unsafe fn from_superset_unchecked(t: &Transform<N2, D, C2>) -> Self {
|
2016-12-05 05:44:42 +08:00
|
|
|
Self::from_superset_unchecked(t.matrix())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-03 01:37:44 +08:00
|
|
|
impl<N1, N2, D: DimName, C> SubsetOf<MatrixN<N2, DimNameSum<D, U1>>> for Transform<N1, D, C>
|
2018-02-02 19:26:35 +08:00
|
|
|
where
|
2019-03-25 18:21:41 +08:00
|
|
|
N1: RealField + SubsetOf<N2>,
|
|
|
|
N2: RealField,
|
2018-02-02 19:26:35 +08:00
|
|
|
C: TCategory,
|
|
|
|
D: DimNameAdd<U1>,
|
|
|
|
DefaultAllocator: Allocator<N1, DimNameSum<D, U1>, DimNameSum<D, U1>>
|
|
|
|
+ Allocator<N2, DimNameSum<D, U1>, DimNameSum<D, U1>>,
|
|
|
|
N1::Epsilon: Copy,
|
|
|
|
N2::Epsilon: Copy,
|
|
|
|
{
|
2016-12-05 05:44:42 +08:00
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn to_superset(&self) -> MatrixN<N2, DimNameSum<D, U1>> {
|
2016-12-05 05:44:42 +08:00
|
|
|
self.matrix().to_superset()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
fn is_in_subset(m: &MatrixN<N2, DimNameSum<D, U1>>) -> bool {
|
2016-12-05 05:44:42 +08:00
|
|
|
C::check_homogeneous_invariants(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2017-08-03 01:37:44 +08:00
|
|
|
unsafe fn from_superset_unchecked(m: &MatrixN<N2, DimNameSum<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
|
|
|
|
2019-03-25 18:21:41 +08:00
|
|
|
impl<N: RealField, D: DimName, C> From<Transform<N, D, C>> for MatrixN<N, DimNameSum<D, U1>>
|
2018-10-13 16:25:34 +08:00
|
|
|
where
|
|
|
|
D: DimNameAdd<U1>,
|
|
|
|
C: TCategory,
|
|
|
|
DefaultAllocator: Allocator<N, DimNameSum<D, U1>, DimNameSum<D, U1>>,
|
|
|
|
{
|
|
|
|
#[inline]
|
|
|
|
fn from(t: Transform<N, D, C>) -> Self {
|
|
|
|
t.to_homogeneous()
|
|
|
|
}
|
|
|
|
}
|