diff --git a/codegen/templates/mat.rs.tera b/codegen/templates/mat.rs.tera index 4b366970..2fb7856d 100644 --- a/codegen/templates/mat.rs.tera +++ b/codegen/templates/mat.rs.tera @@ -302,14 +302,28 @@ impl {{ self_t }} { /// Creates a `[{{ scalar_t }}; {{ size }}]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [{{ scalar_t }}; {{ size }}] { - [ - {% for axis in axes %} - {% for c in components %} - self.{{ axis }}.{{ c }}, + pub const fn to_cols_array(&self) -> [{{ scalar_t }}; {{ size }}] { + {% if self_t == "Mat2" and not is_scalar %} + unsafe { *(self as *const Self as *const [f32; 4]) } + {% else %} + {% if dim >= 2 and not is_scalar %} + {% for axis in axes %} + let [{% for c in components %} {{ axis }}_{{ c }}, {% endfor %}] = self.{{ axis }}.to_array(); {%- endfor %} - {%- endfor %} - ] + {% endif %} + + [ + {% for axis in axes %} + {% for c in components %} + {% if dim >= 2 and not is_scalar %} + {{ axis }}_{{ c }}, + {% else %} + self.{{ axis }}.{{ c }}, + {% endif %} + {%- endfor %} + {%- endfor %} + ] + {% endif %} } /// Creates a {{ nxn }} matrix from a `[[{{ scalar_t }}; {{ dim }}]; {{ dim }}]` {{ dim }}D array stored in column major order. @@ -327,50 +341,50 @@ impl {{ self_t }} { /// Creates a `[[{{ scalar_t }}; {{ dim }}]; {{ dim }}]` {{ dim }}D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[{{ scalar_t }}; {{ dim }}]; {{ dim }}] { - [ - {% for axis in axes %} + pub const fn to_cols_array_2d(&self) -> [[{{ scalar_t }}; {{ dim }}]; {{ dim }}] { + {% if self_t == "Mat2" and not is_scalar %} + unsafe { *(self as *const Self as *const [[f32; 2]; 2]) } + {% else %} + [ + {% for axis in axes %} self.{{ axis }}.to_array(), - {%- endfor %} - ] - } -{% if dim == 4 and vecn_t != "DVec4" %} - /// Creates a {{ nxn }} matrix with its diagonal set to `diagonal` and all other entries set to 0. - #[doc(alias = "scale")] - #[inline] - pub const fn from_diagonal(diagonal: {{ vecn_t }}) -> Self { - // diagonal.x, diagonal.y etc can't be done in a const-context - let [x, y, z, w] = diagonal.to_array(); - Self::new( - {% for i in range(end = dim) %} - {% for j in range(end = dim) %} - {% if i == j %} - {{ components[i] }}, - {% else %} - 0.0, - {% endif %} {%- endfor %} - {%- endfor %} - ) + ] + {% endif %} } -{% else %} + /// Creates a {{ nxn }} matrix with its diagonal set to `diagonal` and all other entries set to 0. #[doc(alias = "scale")] #[inline] pub const fn from_diagonal(diagonal: {{ vecn_t }}) -> Self { - Self::new( - {% for i in range(end = dim) %} - {% for j in range(end = dim) %} - {% if i == j %} - diagonal.{{ components[i] }}, - {% else %} - 0.0, - {% endif %} + {% if self_t == "Mat4" and not is_scalar %} + // diagonal.x, diagonal.y etc can't be done in a const-context + let [x, y, z, w] = diagonal.to_array(); + Self::new( + {% for i in range(end = dim) %} + {% for j in range(end = dim) %} + {% if i == j %} + {{ components[i] }}, + {% else %} + 0.0, + {% endif %} + {%- endfor %} {%- endfor %} - {%- endfor %} - ) + ) + {% else %} + Self::new( + {% for i in range(end = dim) %} + {% for j in range(end = dim) %} + {% if i == j %} + diagonal.{{ components[i] }}, + {% else %} + 0.0, + {% endif %} + {%- endfor %} + {%- endfor %} + ) + {% endif %} } -{% endif %} {% if dim == 2 %} /// Creates a {{ nxn }} matrix containing the combining non-uniform `scale` and rotation of diff --git a/src/f32/coresimd/mat2.rs b/src/f32/coresimd/mat2.rs index 2e63446a..276816fa 100644 --- a/src/f32/coresimd/mat2.rs +++ b/src/f32/coresimd/mat2.rs @@ -56,8 +56,8 @@ impl Mat2 { /// Creates a `[f32; 4]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 4] { - [self.x_axis.x, self.x_axis.y, self.y_axis.x, self.y_axis.y] + pub const fn to_cols_array(&self) -> [f32; 4] { + unsafe { *(self as *const Self as *const [f32; 4]) } } /// Creates a 2x2 matrix from a `[[f32; 2]; 2]` 2D array stored in column major order. @@ -71,8 +71,8 @@ impl Mat2 { /// Creates a `[[f32; 2]; 2]` 2D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 2]; 2] { - [self.x_axis.to_array(), self.y_axis.to_array()] + pub const fn to_cols_array_2d(&self) -> [[f32; 2]; 2] { + unsafe { *(self as *const Self as *const [[f32; 2]; 2]) } } /// Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. diff --git a/src/f32/coresimd/mat3a.rs b/src/f32/coresimd/mat3a.rs index 8c14461d..bda6d275 100644 --- a/src/f32/coresimd/mat3a.rs +++ b/src/f32/coresimd/mat3a.rs @@ -101,17 +101,14 @@ impl Mat3A { /// Creates a `[f32; 9]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 9] { + pub const fn to_cols_array(&self) -> [f32; 9] { + let [x_axis_x, x_axis_y, x_axis_z] = self.x_axis.to_array(); + let [y_axis_x, y_axis_y, y_axis_z] = self.y_axis.to_array(); + let [z_axis_x, z_axis_y, z_axis_z] = self.z_axis.to_array(); + [ - self.x_axis.x, - self.x_axis.y, - self.x_axis.z, - self.y_axis.x, - self.y_axis.y, - self.y_axis.z, - self.z_axis.x, - self.z_axis.y, - self.z_axis.z, + x_axis_x, x_axis_y, x_axis_z, y_axis_x, y_axis_y, y_axis_z, z_axis_x, z_axis_y, + z_axis_z, ] } @@ -130,7 +127,7 @@ impl Mat3A { /// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 3]; 3] { + pub const fn to_cols_array_2d(&self) -> [[f32; 3]; 3] { [ self.x_axis.to_array(), self.y_axis.to_array(), diff --git a/src/f32/coresimd/mat4.rs b/src/f32/coresimd/mat4.rs index 99639727..d8a86f47 100644 --- a/src/f32/coresimd/mat4.rs +++ b/src/f32/coresimd/mat4.rs @@ -119,24 +119,15 @@ impl Mat4 { /// Creates a `[f32; 16]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 16] { + pub const fn to_cols_array(&self) -> [f32; 16] { + let [x_axis_x, x_axis_y, x_axis_z, x_axis_w] = self.x_axis.to_array(); + let [y_axis_x, y_axis_y, y_axis_z, y_axis_w] = self.y_axis.to_array(); + let [z_axis_x, z_axis_y, z_axis_z, z_axis_w] = self.z_axis.to_array(); + let [w_axis_x, w_axis_y, w_axis_z, w_axis_w] = self.w_axis.to_array(); + [ - self.x_axis.x, - self.x_axis.y, - self.x_axis.z, - self.x_axis.w, - self.y_axis.x, - self.y_axis.y, - self.y_axis.z, - self.y_axis.w, - self.z_axis.x, - self.z_axis.y, - self.z_axis.z, - self.z_axis.w, - self.w_axis.x, - self.w_axis.y, - self.w_axis.z, - self.w_axis.w, + x_axis_x, x_axis_y, x_axis_z, x_axis_w, y_axis_x, y_axis_y, y_axis_z, y_axis_w, + z_axis_x, z_axis_y, z_axis_z, z_axis_w, w_axis_x, w_axis_y, w_axis_z, w_axis_w, ] } @@ -156,7 +147,7 @@ impl Mat4 { /// Creates a `[[f32; 4]; 4]` 4D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 4]; 4] { + pub const fn to_cols_array_2d(&self) -> [[f32; 4]; 4] { [ self.x_axis.to_array(), self.y_axis.to_array(), diff --git a/src/f32/mat3.rs b/src/f32/mat3.rs index 1839e297..6c2ed4da 100644 --- a/src/f32/mat3.rs +++ b/src/f32/mat3.rs @@ -99,7 +99,7 @@ impl Mat3 { /// Creates a `[f32; 9]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 9] { + pub const fn to_cols_array(&self) -> [f32; 9] { [ self.x_axis.x, self.x_axis.y, @@ -128,7 +128,7 @@ impl Mat3 { /// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 3]; 3] { + pub const fn to_cols_array_2d(&self) -> [[f32; 3]; 3] { [ self.x_axis.to_array(), self.y_axis.to_array(), diff --git a/src/f32/scalar/mat2.rs b/src/f32/scalar/mat2.rs index da98c688..03d082ef 100644 --- a/src/f32/scalar/mat2.rs +++ b/src/f32/scalar/mat2.rs @@ -65,7 +65,7 @@ impl Mat2 { /// Creates a `[f32; 4]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 4] { + pub const fn to_cols_array(&self) -> [f32; 4] { [self.x_axis.x, self.x_axis.y, self.y_axis.x, self.y_axis.y] } @@ -80,7 +80,7 @@ impl Mat2 { /// Creates a `[[f32; 2]; 2]` 2D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 2]; 2] { + pub const fn to_cols_array_2d(&self) -> [[f32; 2]; 2] { [self.x_axis.to_array(), self.y_axis.to_array()] } diff --git a/src/f32/scalar/mat3a.rs b/src/f32/scalar/mat3a.rs index e72c8f02..ea569812 100644 --- a/src/f32/scalar/mat3a.rs +++ b/src/f32/scalar/mat3a.rs @@ -99,7 +99,7 @@ impl Mat3A { /// Creates a `[f32; 9]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 9] { + pub const fn to_cols_array(&self) -> [f32; 9] { [ self.x_axis.x, self.x_axis.y, @@ -128,7 +128,7 @@ impl Mat3A { /// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 3]; 3] { + pub const fn to_cols_array_2d(&self) -> [[f32; 3]; 3] { [ self.x_axis.to_array(), self.y_axis.to_array(), diff --git a/src/f32/scalar/mat4.rs b/src/f32/scalar/mat4.rs index f2de316e..580eb279 100644 --- a/src/f32/scalar/mat4.rs +++ b/src/f32/scalar/mat4.rs @@ -124,7 +124,7 @@ impl Mat4 { /// Creates a `[f32; 16]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 16] { + pub const fn to_cols_array(&self) -> [f32; 16] { [ self.x_axis.x, self.x_axis.y, @@ -161,7 +161,7 @@ impl Mat4 { /// Creates a `[[f32; 4]; 4]` 4D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 4]; 4] { + pub const fn to_cols_array_2d(&self) -> [[f32; 4]; 4] { [ self.x_axis.to_array(), self.y_axis.to_array(), @@ -174,10 +174,9 @@ impl Mat4 { #[doc(alias = "scale")] #[inline] pub const fn from_diagonal(diagonal: Vec4) -> Self { - // diagonal.x, diagonal.y etc can't be done in a const-context - let [x, y, z, w] = diagonal.to_array(); Self::new( - x, 0.0, 0.0, 0.0, 0.0, y, 0.0, 0.0, 0.0, 0.0, z, 0.0, 0.0, 0.0, 0.0, w, + diagonal.x, 0.0, 0.0, 0.0, 0.0, diagonal.y, 0.0, 0.0, 0.0, 0.0, diagonal.z, 0.0, 0.0, + 0.0, 0.0, diagonal.w, ) } diff --git a/src/f32/sse2/mat2.rs b/src/f32/sse2/mat2.rs index fa7b6079..311448bf 100644 --- a/src/f32/sse2/mat2.rs +++ b/src/f32/sse2/mat2.rs @@ -74,8 +74,8 @@ impl Mat2 { /// Creates a `[f32; 4]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 4] { - [self.x_axis.x, self.x_axis.y, self.y_axis.x, self.y_axis.y] + pub const fn to_cols_array(&self) -> [f32; 4] { + unsafe { *(self as *const Self as *const [f32; 4]) } } /// Creates a 2x2 matrix from a `[[f32; 2]; 2]` 2D array stored in column major order. @@ -89,8 +89,8 @@ impl Mat2 { /// Creates a `[[f32; 2]; 2]` 2D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 2]; 2] { - [self.x_axis.to_array(), self.y_axis.to_array()] + pub const fn to_cols_array_2d(&self) -> [[f32; 2]; 2] { + unsafe { *(self as *const Self as *const [[f32; 2]; 2]) } } /// Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. diff --git a/src/f32/sse2/mat3a.rs b/src/f32/sse2/mat3a.rs index 25fde995..14912dd1 100644 --- a/src/f32/sse2/mat3a.rs +++ b/src/f32/sse2/mat3a.rs @@ -104,17 +104,14 @@ impl Mat3A { /// Creates a `[f32; 9]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 9] { + pub const fn to_cols_array(&self) -> [f32; 9] { + let [x_axis_x, x_axis_y, x_axis_z] = self.x_axis.to_array(); + let [y_axis_x, y_axis_y, y_axis_z] = self.y_axis.to_array(); + let [z_axis_x, z_axis_y, z_axis_z] = self.z_axis.to_array(); + [ - self.x_axis.x, - self.x_axis.y, - self.x_axis.z, - self.y_axis.x, - self.y_axis.y, - self.y_axis.z, - self.z_axis.x, - self.z_axis.y, - self.z_axis.z, + x_axis_x, x_axis_y, x_axis_z, y_axis_x, y_axis_y, y_axis_z, z_axis_x, z_axis_y, + z_axis_z, ] } @@ -133,7 +130,7 @@ impl Mat3A { /// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 3]; 3] { + pub const fn to_cols_array_2d(&self) -> [[f32; 3]; 3] { [ self.x_axis.to_array(), self.y_axis.to_array(), diff --git a/src/f32/sse2/mat4.rs b/src/f32/sse2/mat4.rs index b6a0c622..24e16adc 100644 --- a/src/f32/sse2/mat4.rs +++ b/src/f32/sse2/mat4.rs @@ -122,24 +122,15 @@ impl Mat4 { /// Creates a `[f32; 16]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 16] { + pub const fn to_cols_array(&self) -> [f32; 16] { + let [x_axis_x, x_axis_y, x_axis_z, x_axis_w] = self.x_axis.to_array(); + let [y_axis_x, y_axis_y, y_axis_z, y_axis_w] = self.y_axis.to_array(); + let [z_axis_x, z_axis_y, z_axis_z, z_axis_w] = self.z_axis.to_array(); + let [w_axis_x, w_axis_y, w_axis_z, w_axis_w] = self.w_axis.to_array(); + [ - self.x_axis.x, - self.x_axis.y, - self.x_axis.z, - self.x_axis.w, - self.y_axis.x, - self.y_axis.y, - self.y_axis.z, - self.y_axis.w, - self.z_axis.x, - self.z_axis.y, - self.z_axis.z, - self.z_axis.w, - self.w_axis.x, - self.w_axis.y, - self.w_axis.z, - self.w_axis.w, + x_axis_x, x_axis_y, x_axis_z, x_axis_w, y_axis_x, y_axis_y, y_axis_z, y_axis_w, + z_axis_x, z_axis_y, z_axis_z, z_axis_w, w_axis_x, w_axis_y, w_axis_z, w_axis_w, ] } @@ -159,7 +150,7 @@ impl Mat4 { /// Creates a `[[f32; 4]; 4]` 4D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 4]; 4] { + pub const fn to_cols_array_2d(&self) -> [[f32; 4]; 4] { [ self.x_axis.to_array(), self.y_axis.to_array(), diff --git a/src/f32/wasm32/mat2.rs b/src/f32/wasm32/mat2.rs index ef721b3f..7869ff52 100644 --- a/src/f32/wasm32/mat2.rs +++ b/src/f32/wasm32/mat2.rs @@ -56,8 +56,8 @@ impl Mat2 { /// Creates a `[f32; 4]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 4] { - [self.x_axis.x, self.x_axis.y, self.y_axis.x, self.y_axis.y] + pub const fn to_cols_array(&self) -> [f32; 4] { + unsafe { *(self as *const Self as *const [f32; 4]) } } /// Creates a 2x2 matrix from a `[[f32; 2]; 2]` 2D array stored in column major order. @@ -71,8 +71,8 @@ impl Mat2 { /// Creates a `[[f32; 2]; 2]` 2D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 2]; 2] { - [self.x_axis.to_array(), self.y_axis.to_array()] + pub const fn to_cols_array_2d(&self) -> [[f32; 2]; 2] { + unsafe { *(self as *const Self as *const [[f32; 2]; 2]) } } /// Creates a 2x2 matrix with its diagonal set to `diagonal` and all other entries set to 0. diff --git a/src/f32/wasm32/mat3a.rs b/src/f32/wasm32/mat3a.rs index f5d974a2..573ea1f1 100644 --- a/src/f32/wasm32/mat3a.rs +++ b/src/f32/wasm32/mat3a.rs @@ -101,17 +101,14 @@ impl Mat3A { /// Creates a `[f32; 9]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 9] { + pub const fn to_cols_array(&self) -> [f32; 9] { + let [x_axis_x, x_axis_y, x_axis_z] = self.x_axis.to_array(); + let [y_axis_x, y_axis_y, y_axis_z] = self.y_axis.to_array(); + let [z_axis_x, z_axis_y, z_axis_z] = self.z_axis.to_array(); + [ - self.x_axis.x, - self.x_axis.y, - self.x_axis.z, - self.y_axis.x, - self.y_axis.y, - self.y_axis.z, - self.z_axis.x, - self.z_axis.y, - self.z_axis.z, + x_axis_x, x_axis_y, x_axis_z, y_axis_x, y_axis_y, y_axis_z, z_axis_x, z_axis_y, + z_axis_z, ] } @@ -130,7 +127,7 @@ impl Mat3A { /// Creates a `[[f32; 3]; 3]` 3D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 3]; 3] { + pub const fn to_cols_array_2d(&self) -> [[f32; 3]; 3] { [ self.x_axis.to_array(), self.y_axis.to_array(), diff --git a/src/f32/wasm32/mat4.rs b/src/f32/wasm32/mat4.rs index 9ce0c23f..433e893d 100644 --- a/src/f32/wasm32/mat4.rs +++ b/src/f32/wasm32/mat4.rs @@ -119,24 +119,15 @@ impl Mat4 { /// Creates a `[f32; 16]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f32; 16] { + pub const fn to_cols_array(&self) -> [f32; 16] { + let [x_axis_x, x_axis_y, x_axis_z, x_axis_w] = self.x_axis.to_array(); + let [y_axis_x, y_axis_y, y_axis_z, y_axis_w] = self.y_axis.to_array(); + let [z_axis_x, z_axis_y, z_axis_z, z_axis_w] = self.z_axis.to_array(); + let [w_axis_x, w_axis_y, w_axis_z, w_axis_w] = self.w_axis.to_array(); + [ - self.x_axis.x, - self.x_axis.y, - self.x_axis.z, - self.x_axis.w, - self.y_axis.x, - self.y_axis.y, - self.y_axis.z, - self.y_axis.w, - self.z_axis.x, - self.z_axis.y, - self.z_axis.z, - self.z_axis.w, - self.w_axis.x, - self.w_axis.y, - self.w_axis.z, - self.w_axis.w, + x_axis_x, x_axis_y, x_axis_z, x_axis_w, y_axis_x, y_axis_y, y_axis_z, y_axis_w, + z_axis_x, z_axis_y, z_axis_z, z_axis_w, w_axis_x, w_axis_y, w_axis_z, w_axis_w, ] } @@ -156,7 +147,7 @@ impl Mat4 { /// Creates a `[[f32; 4]; 4]` 4D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f32; 4]; 4] { + pub const fn to_cols_array_2d(&self) -> [[f32; 4]; 4] { [ self.x_axis.to_array(), self.y_axis.to_array(), diff --git a/src/f64/dmat2.rs b/src/f64/dmat2.rs index 3f79adf6..bd52c8c3 100644 --- a/src/f64/dmat2.rs +++ b/src/f64/dmat2.rs @@ -61,7 +61,7 @@ impl DMat2 { /// Creates a `[f64; 4]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f64; 4] { + pub const fn to_cols_array(&self) -> [f64; 4] { [self.x_axis.x, self.x_axis.y, self.y_axis.x, self.y_axis.y] } @@ -76,7 +76,7 @@ impl DMat2 { /// Creates a `[[f64; 2]; 2]` 2D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f64; 2]; 2] { + pub const fn to_cols_array_2d(&self) -> [[f64; 2]; 2] { [self.x_axis.to_array(), self.y_axis.to_array()] } diff --git a/src/f64/dmat3.rs b/src/f64/dmat3.rs index adf6cbf6..600223cb 100644 --- a/src/f64/dmat3.rs +++ b/src/f64/dmat3.rs @@ -99,7 +99,7 @@ impl DMat3 { /// Creates a `[f64; 9]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f64; 9] { + pub const fn to_cols_array(&self) -> [f64; 9] { [ self.x_axis.x, self.x_axis.y, @@ -128,7 +128,7 @@ impl DMat3 { /// Creates a `[[f64; 3]; 3]` 3D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f64; 3]; 3] { + pub const fn to_cols_array_2d(&self) -> [[f64; 3]; 3] { [ self.x_axis.to_array(), self.y_axis.to_array(), diff --git a/src/f64/dmat4.rs b/src/f64/dmat4.rs index cac5d550..cc4283c2 100644 --- a/src/f64/dmat4.rs +++ b/src/f64/dmat4.rs @@ -118,7 +118,7 @@ impl DMat4 { /// Creates a `[f64; 16]` array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array(&self) -> [f64; 16] { + pub const fn to_cols_array(&self) -> [f64; 16] { [ self.x_axis.x, self.x_axis.y, @@ -155,7 +155,7 @@ impl DMat4 { /// Creates a `[[f64; 4]; 4]` 4D array storing data in column major order. /// If you require data in row major order `transpose` the matrix first. #[inline] - pub fn to_cols_array_2d(&self) -> [[f64; 4]; 4] { + pub const fn to_cols_array_2d(&self) -> [[f64; 4]; 4] { [ self.x_axis.to_array(), self.y_axis.to_array(),