1use crate::{
2 matrix::{impl_matrix, AsMutMatrixParts, AsRefMatrixParts, FromMatrixParts, MatrixScalar},
3 vector::{impl_vector, AsMutVectorParts, AsRefVectorParts, FromVectorParts, VectorScalar},
4};
5
6impl_vector!(2, nalgebra::VectorView2<'_, T>);
7impl_vector!(2, nalgebra::VectorViewMut2<'_, T>);
8impl_vector!(2, nalgebra::Vector2<T>);
9
10impl_vector!(3, nalgebra::VectorView3<'_, T>);
11impl_vector!(3, nalgebra::VectorViewMut3<'_, T>);
12impl_vector!(3, nalgebra::Vector3<T>);
13
14impl_vector!(4, nalgebra::VectorView4<'_, T>);
15impl_vector!(4, nalgebra::VectorViewMut4<'_, T>);
16impl_vector!(4, nalgebra::Vector4<T>);
17
18impl_matrix!(2, 2, nalgebra::MatrixView2<'_, T>);
19impl_matrix!(2, 2, nalgebra::MatrixViewMut2<'_, T>);
20impl_matrix!(2, 2, nalgebra::Matrix2<T>);
21
22impl_matrix!(3, 2, nalgebra::MatrixView2x3<'_, T>);
23impl_matrix!(4, 2, nalgebra::MatrixView2x4<'_, T>);
24impl_matrix!(2, 3, nalgebra::MatrixView3x2<'_, T>);
25impl_matrix!(3, 2, nalgebra::MatrixViewMut2x3<'_, T>);
26impl_matrix!(4, 2, nalgebra::MatrixViewMut2x4<'_, T>);
27impl_matrix!(2, 3, nalgebra::MatrixViewMut3x2<'_, T>);
28impl_matrix!(3, 2, nalgebra::Matrix2x3<T>);
29impl_matrix!(4, 2, nalgebra::Matrix2x4<T>);
30impl_matrix!(2, 3, nalgebra::Matrix3x2<T>);
31
32impl_matrix!(3, 3, nalgebra::MatrixView3<'_, T>);
33impl_matrix!(3, 3, nalgebra::MatrixViewMut3<'_, T>);
34impl_matrix!(3, 3, nalgebra::Matrix3<T>);
35
36impl_matrix!(4, 3, nalgebra::MatrixView3x4<'_, T>);
37impl_matrix!(2, 4, nalgebra::MatrixView4x2<'_, T>);
38impl_matrix!(3, 4, nalgebra::MatrixView4x3<'_, T>);
39impl_matrix!(4, 3, nalgebra::MatrixViewMut3x4<'_, T>);
40impl_matrix!(2, 4, nalgebra::MatrixViewMut4x2<'_, T>);
41impl_matrix!(3, 4, nalgebra::MatrixViewMut4x3<'_, T>);
42impl_matrix!(4, 3, nalgebra::Matrix3x4<T>);
43impl_matrix!(2, 4, nalgebra::Matrix4x2<T>);
44impl_matrix!(3, 4, nalgebra::Matrix4x3<T>);
45
46impl_matrix!(4, 4, nalgebra::MatrixView4<'_, T>);
47impl_matrix!(4, 4, nalgebra::MatrixViewMut4<'_, T>);
48impl_matrix!(4, 4, nalgebra::Matrix4<T>);
49
50impl<T: VectorScalar, S, const N: usize> AsRefVectorParts<T, N>
51 for nalgebra::Matrix<T, nalgebra::Const<N>, nalgebra::Const<1>, S>
52where
53 Self: AsRef<[T; N]>,
54{
55 fn as_ref_parts(&self) -> &[T; N] {
56 self.as_ref()
57 }
58}
59
60impl<T: VectorScalar, S, const N: usize> AsMutVectorParts<T, N>
61 for nalgebra::Matrix<T, nalgebra::Const<N>, nalgebra::Const<1>, S>
62where
63 Self: AsMut<[T; N]>,
64{
65 fn as_mut_parts(&mut self) -> &mut [T; N] {
66 self.as_mut()
67 }
68}
69
70impl<T: VectorScalar, const N: usize> FromVectorParts<T, N> for nalgebra::SMatrix<T, N, 1> {
71 fn from_parts(parts: [T; N]) -> Self {
72 Self::from_array_storage(nalgebra::ArrayStorage([parts]))
73 }
74}
75
76impl<T: MatrixScalar, S, const C: usize, const R: usize> AsRefMatrixParts<T, C, R>
77 for nalgebra::Matrix<T, nalgebra::Const<R>, nalgebra::Const<C>, S>
78where
79 Self: AsRef<[[T; R]; C]>,
80{
81 fn as_ref_parts(&self) -> &[[T; R]; C] {
82 self.as_ref()
83 }
84}
85
86impl<T: MatrixScalar, S, const C: usize, const R: usize> AsMutMatrixParts<T, C, R>
87 for nalgebra::Matrix<T, nalgebra::Const<R>, nalgebra::Const<C>, S>
88where
89 Self: AsMut<[[T; R]; C]>,
90{
91 fn as_mut_parts(&mut self) -> &mut [[T; R]; C] {
92 self.as_mut()
93 }
94}
95
96impl<T: MatrixScalar, const C: usize, const R: usize> FromMatrixParts<T, C, R>
97 for nalgebra::SMatrix<T, R, C>
98{
99 fn from_parts(parts: [[T; R]; C]) -> Self {
100 Self::from_array_storage(nalgebra::ArrayStorage(parts))
101 }
102}