1impl super::F3lMatrix for glam::Vec4 {
2 type RowType = [f32; 1];
3
4 #[inline]
5 fn cols(&self) -> usize {
6 1
7 }
8
9 #[inline]
10 fn rows(&self) -> usize {
11 4
12 }
13
14 #[inline]
15 fn row(&self, r: usize) -> Self::RowType {
16 [self[r]]
17 }
18
19 #[inline]
20 fn get(&self, r: usize, _: usize) -> Option<f32> {
21 match r {
22 0 => Some(self.x),
23 1 => Some(self.y),
24 2 => Some(self.z),
25 3 => Some(self.w),
26 _ => None,
27 }
28 }
29
30 #[inline]
31 fn set_row<R: Into<Self::RowType> + Copy>(&mut self, row: usize, v: R) {
32 if row >= 1 {
33 return;
34 }
35 self[row] = v.into()[0];
36 }
37
38 #[inline]
39 fn set_element(&mut self, pos: (usize, usize), v: f32) {
40 if pos.1 >= 1 {
41 return;
42 }
43 self[pos.0] = v;
44 }
45}
46
47impl super::ArrayRowMajor for glam::Vec4 {
48 type Row = [f32; 4];
49
50 type Mat = [[f32; 1]; 4];
51
52 #[inline]
53 fn from_rows<R: std::ops::Index<usize, Output = f32>>(rows: &[R]) -> Self {
54 Self::new(rows[0][0], rows[0][1], rows[0][3], rows[0][3])
55 }
56
57 #[inline]
58 fn from_rows_slice(m: &[f32]) -> Self {
59 Self::from_slice(m)
60 }
61
62 #[inline]
63 fn to_rows_array(&self) -> Self::Row {
64 (*self).into()
65 }
66
67 #[inline]
68 fn from_cols_array_2d(m: &Self::Mat) -> Self {
69 Self::new(m[0][0], m[1][0], m[2][0], m[3][0])
70 }
71
72 #[inline]
73 fn to_rows_array_2d(&self) -> Self::Mat {
74 [[self.x], [self.y], [self.z], [self.w]]
75 }
76
77 #[inline]
78 fn write_rows_to_slice(self, slice: &mut [f32]) {
79 self.write_to_slice(slice)
80 }
81}
82
83impl super::ArrayDimensions for glam::Vec4 {
84 fn nb_cols() -> usize {
85 4
86 }
87
88 fn nb_rows() -> usize {
89 1
90 }
91}
92impl super::GenericArray for glam::Vec4 {}