nalgebra/geometry/
transform_construction.rs1use num::One;
2
3use simba::scalar::RealField;
4
5use crate::base::allocator::Allocator;
6use crate::base::dimension::{DimNameAdd, DimNameSum, U1};
7use crate::base::{Const, DefaultAllocator, OMatrix};
8
9use crate::geometry::{TCategory, Transform};
10
11impl<T: RealField, C: TCategory, const D: usize> Default for Transform<T, C, D>
12where
13 Const<D>: DimNameAdd<U1>,
14 DefaultAllocator: Allocator<DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
15{
16 fn default() -> Self {
17 Self::identity()
18 }
19}
20
21impl<T: RealField, C: TCategory, const D: usize> Transform<T, C, D>
22where
23 Const<D>: DimNameAdd<U1>,
24 DefaultAllocator: Allocator<DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
25{
26 #[inline]
55 pub fn identity() -> Self {
56 Self::from_matrix_unchecked(OMatrix::<
57 _,
58 DimNameSum<Const<D>, U1>,
59 DimNameSum<Const<D>, U1>,
60 >::identity())
61 }
62}
63
64impl<T: RealField, C: TCategory, const D: usize> One for Transform<T, C, D>
65where
66 Const<D>: DimNameAdd<U1>,
67 DefaultAllocator: Allocator<DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
68{
69 #[inline]
71 fn one() -> Self {
72 Self::identity()
73 }
74}