Repository: bitshifter/glam-rs
Pull request #206 (2021-06-25 09:54:09)

From matn


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 68a0ba7..eb2dd24 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,12 @@ The format is based on [Keep a Changelog], and this project adheres to
 
 * The addition of `Add` and `Sub` implementations of scalar values for vector
   types may create ambiguities with existing calls to `add` and `sub`.
+* Removed `From<Mat3>` implementation for `Mat2` and `From<DMat3>` for `DMat2`.
+  These have been replaced by `Mat2::from_mat3()` and `DMat2::from_mat3()`.
+* Removed `From<Mat4>` implementation for `Mat3` and `From<DMat4>` for `DMat3`.
+  These have been replaced by `Mat3::from_mat4()` and `DMat3::from_mat4()`.
+* Removed deprecated `from_slice_unaligned()`, `write_to_slice_unaligned()`,
+  `from_rotation_mat4` and `from_rotation_ypr()` methods.
 
 ### Added
 
@@ -19,15 +25,21 @@ The format is based on [Keep a Changelog], and this project adheres to
 * Added `AddAssign`, `MulAssign` and `SubAssign` implementations for all matrix
   types.
 * Added `Add` and `Sub` implementations of scalar values for vector types.
-* Added more `glam_assert` checks and documented methods where they are used.
+* Added more `glam_assert!` checks and documented methods where they are used.
 * Added vector projection and rejection methods `project_onto()`,
   `project_onto_normalized()`, `reject_from()` and `reject_from_normalized()`.
+* Added `Mat2::from_mat3()`, `DMat2::from_mat3()`, `Mat3::from_mat4()`,
+  `DMat3::from_mat4()` which create a smaller matrix from a larger one,
+  discarding a final row and column of the input matrix.
+* Added `Mat3::from_mat2()`, `DMat3::from_mat2()`, `Mat4::from_mat3()` and
+  `DMat4::from_mat3()` which create an affine transform from a smaller linear
+  transform matrix.
 
 ### Changed
 
 * Don't support `AsRef` and `AsMut` on SPIR-V targets. Also removed SPIR-V
-  support for some methods that used `as_ref`, including `hash`. Not a breaking
-  change as these methods would not have worked anyway.
+  support for some methods that used `as_ref()`, including `hash()`. Not a
+  breaking change as these methods would not have worked anyway.
 
 ### Fixed
 
@@ -39,8 +51,8 @@ The format is based on [Keep a Changelog], and this project adheres to
 
 * `sprirv-std` dependency was removed, rust-gpu depends on glam internally
   again for now.
-* Added `must_use` attribute to all `inverse`, `normalize`, `try_normalize`,
-  `transpose` and `conjugate` methods.
+* Added `must_use` attribute to all `inverse()`, `normalize()`,
+  `try_normalize()`, `transpose()` and `conjugate()` methods.
 
 ### Added
 
diff --git a/src/mat2.rs b/src/mat2.rs
index 82a6bd5..e520bd8 100644
--- a/src/mat2.rs
+++ b/src/mat2.rs
@@ -24,7 +24,7 @@ use core::arch::x86_64::*;
 use std::iter::{Product, Sum};
 
 macro_rules! impl_mat2_methods {
-    ($t:ty, $vec2:ident, $inner:ident) => {
+    ($t:ty, $vec2:ident, $mat3:ident, $inner:ident) => {
         /// A 2x2 matrix with all elements set to `0.0`.
         pub const ZERO: Self = Self($inner::ZERO);
 
@@ -87,6 +87,12 @@ macro_rules! impl_mat2_methods {
             Self($inner::from_angle(angle))
         }
 
+        /// Creates a 2x2 matrix from a 3x3 matrix, discarding the 2nd row and column.
+        #[inline(always)]
+        pub fn from_mat3(m: $mat3) -> Self {
+            Self::from_cols(m.x_axis.into(), m.y_axis.into())
+        }
+
         /// Creates a 2x2 matrix from the first 4 values in `slice`.
         ///
         /// # Panics
@@ -236,7 +242,7 @@ macro_rules! impl_mat2_methods {
 }
 
 macro_rules! impl_mat2_traits {
-    ($t:ty, $new:ident, $mat2:ident, $mat3:ident, $vec2:ident) => {
+    ($t:ty, $new:ident, $mat2:ident, $vec2:ident) => {
         /// Creates a 2x2 matrix from two column vectors.
         #[inline(always)]
         pub fn $new(x_axis: $vec2, y_axis: $vec2) -> $mat2 {
@@ -283,13 +289,6 @@ macro_rules! impl_mat2_traits {
             }
         }
 
-        impl From<$mat3> for $mat2 {
-            /// Creates a 2x2 matrix from the top left submatrix of the given 3x3 matrix.
-            fn from(m: $mat3) -> $mat2 {
-                $mat2::from_cols(m.x_axis.into(), m.y_axis.into())
-            }
-        }
-
         #[cfg(not(target_arch = "spirv"))]
         impl fmt::Debug for $mat2 {
             fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
@@ -325,14 +324,14 @@ type InnerF32 = crate::core::storage::Columns2<XY<f32>>;
 pub struct Mat2(pub(crate) InnerF32);
 
 impl Mat2 {
-    impl_mat2_methods!(f32, Vec2, InnerF32);
+    impl_mat2_methods!(f32, Vec2, Mat3, InnerF32);
 
     #[inline(always)]
     pub fn as_f64(&self) -> DMat2 {
         DMat2::from_cols(self.x_axis.as_f64(), self.y_axis.as_f64())
     }
 }
-impl_mat2_traits!(f32, mat2, Mat2, Mat3, Vec2);
+impl_mat2_traits!(f32, mat2, Mat2, Vec2);
 
 type InnerF64 = crate::core::storage::Columns2<XY<f64>>;
 
@@ -342,14 +341,14 @@ type InnerF64 = crate::core::storage::Columns2<XY<f64>>;
 pub struct DMat2(pub(crate) InnerF64);
 
 impl DMat2 {
-    impl_mat2_methods!(f64, DVec2, InnerF64);
+    impl_mat2_methods!(f64, DVec2, DMat3, InnerF64);
 
     #[inline(always)]
     pub fn as_f32(&self) -> Mat2 {
         Mat2::from_cols(self.x_axis.as_f32(), self.y_axis.as_f32())
     }
 }
-impl_mat2_traits!(f64, dmat2, DMat2, DMat3, DVec2);
+impl_mat2_traits!(f64, dmat2, DMat2, DVec2);
 
 #[cfg(any(feature = "scalar-math", target_arch = "spriv"))]
 mod const_test_mat2 {
diff --git a/src/mat3.rs b/src/mat3.rs
index 26b4b5f..5a025a1 100644
--- a/src/mat3.rs
+++ b/src/mat3.rs
@@ -56,7 +56,7 @@ macro_rules! define_mat3_struct {
 }
 
 macro_rules! impl_mat3_methods {
-    ($t:ty, $vec3:ident, $vec3a:ident, $vec2:ident, $quat:ident, $mat2:ident, $inner:ident) => {
+    ($t:ty, $vec3:ident, $vec3a:ident, $vec2:ident, $quat:ident, $mat2:ident, $mat4:ident, $inner:ident) => {
         /// A 3x3 matrix with all elements set to `0.0`.
         pub const ZERO: Self = Self($inner::ZERO);
 
@@ -108,12 +108,17 @@ macro_rules! impl_mat3_methods {
             Self($inner::from_diagonal(diagonal.0))
         }
 
-        #[inline(always)]
+        /// Creates a 3x3 matrix from a 4x4 matrix, discarding the 3rd row and column.
+        pub fn from_mat4(m: $mat4) -> Self {
+            Self::from_cols(m.x_axis.into(), m.y_axis.into(), m.z_axis.into())
+        }
+
         /// Creates a 3D rotation matrix from the given quaternion.
         ///
         /// # Panics
         ///
         /// Will panic if `rotation` is not normalized when `glam_assert` is enabled.
+        #[inline(always)]
         pub fn from_quat(rotation: $quat) -> Self {
             // TODO: SIMD?
             Self($inner::from_quaternion(rotation.0.into()))
@@ -130,15 +135,6 @@ macro_rules! impl_mat3_methods {
             Self(FloatMatrix3x3::from_axis_angle(axis.0, angle))
         }
 
-        #[deprecated(
-            since = "0.15.0",
-            note = "Please use `from_euler(EulerRot::YXZ, yaw, pitch, roll)` instead"
-        )]
-        #[inline(always)]
-        pub fn from_rotation_ypr(yaw: $t, pitch: $t, roll: $t) -> Self {
-            Self::from_euler(EulerRot::YXZ, yaw, pitch, roll)
-        }
-
         #[inline(always)]
         /// Creates a 3D rotation matrix from the given euler rotation sequence and the angles (in
         /// radians).
@@ -211,6 +207,15 @@ macro_rules! impl_mat3_methods {
             Self(Matrix3x3::from_scale(scale.0))
         }
 
+        /// Creates an affine transformation matrix from the given 2x2 matrix.
+        ///
+        /// The resulting matrix can be used to transform 2D points and vectors. See
+        /// [`Self::transform_point2()`] and [`Self::transform_vector2()`].
+        #[inline(always)]
+        pub fn from_mat2(m: $mat2) -> Self {
+            Self::from_cols((m.x_axis, 0.0).into(), (m.y_axis, 0.0).into(), $vec3a::Z)
+        }
+
         /// Creates a 3x3 matrix from the first 9 values in `slice`.
         ///
         /// # Panics
@@ -383,7 +388,7 @@ macro_rules! impl_mat3_methods {
 }
 
 macro_rules! impl_mat3_traits {
-    ($t:ty, $new:ident, $mat3:ident, $mat4:ident, $vec3:ident, $vec3a:ident) => {
+    ($t:ty, $new:ident, $mat3:ident, $vec3:ident, $vec3a:ident) => {
         /// Creates a 3x3 matrix from three column vectors.
         #[inline(always)]
         pub fn $new(x_axis: $vec3a, y_axis: $vec3a, z_axis: $vec3a) -> $mat3 {
@@ -433,13 +438,6 @@ macro_rules! impl_mat3_traits {
                     .finish()
             }
         }
-
-        impl From<$mat4> for $mat3 {
-            /// Creates a 3x3 matrix from the top left submatrix of the given 4x4 matrix.
-            fn from(m: $mat4) -> $mat3 {
-                $mat3::from_cols(m.x_axis.into(), m.y_axis.into(), m.z_axis.into())
-            }
-        }
     };
 }
 
@@ -467,7 +465,7 @@ type InnerF32 = Columns3<XYZ<f32>>;
 define_mat3_struct!(Mat3, InnerF32);
 
 impl Mat3 {
-    impl_mat3_methods!(f32, Vec3, Vec3, Vec2, Quat, Mat2, InnerF32);
+    impl_mat3_methods!(f32, Vec3, Vec3, Vec2, Quat, Mat2, Mat4, InnerF32);
 
     /// Transforms a `Vec3A`.
     #[inline]
@@ -484,7 +482,7 @@ impl Mat3 {
         )
     }
 }
-impl_mat3_traits!(f32, mat3, Mat3, Mat4, Vec3, Vec3);
+impl_mat3_traits!(f32, mat3, Mat3, Vec3, Vec3);
 impl_mat3_traits_unsafe!(f32, Mat3);
 
 impl Mul<Vec3A> for Mat3 {
@@ -502,7 +500,7 @@ type InnerF32A = Columns3<crate::core::storage::XYZF32A16>;
 define_mat3_struct!(Mat3A, InnerF32A);
 
 impl Mat3A {
-    impl_mat3_methods!(f32, Vec3, Vec3A, Vec2, Quat, Mat2, InnerF32A);
+    impl_mat3_methods!(f32, Vec3, Vec3A, Vec2, Quat, Mat2, Mat4, InnerF32A);
 
     /// Transforms a `Vec3A`.
     #[inline]
@@ -519,7 +517,7 @@ impl Mat3A {
         )
     }
 }
-impl_mat3_traits!(f32, mat3a, Mat3A, Mat4, Vec3, Vec3A);
+impl_mat3_traits!(f32, mat3a, Mat3A, Vec3, Vec3A);
 
 impl Mul<Vec3> for Mat3A {
     type Output = Vec3;
@@ -547,7 +545,7 @@ type InnerF64 = Columns3<XYZ<f64>>;
 define_mat3_struct!(DMat3, InnerF64);
 
 impl DMat3 {
-    impl_mat3_methods!(f64, DVec3, DVec3, DVec2, DQuat, DMat2, InnerF64);
+    impl_mat3_methods!(f64, DVec3, DVec3, DVec2, DQuat, DMat2, DMat4, InnerF64);
 
     #[inline(always)]
     pub fn as_f32(&self) -> Mat3 {
@@ -558,7 +556,7 @@ impl DMat3 {
         )
     }
 }
-impl_mat3_traits!(f64, dmat3, DMat3, DMat4, DVec3, DVec3);
+impl_mat3_traits!(f64, dmat3, DMat3, DVec3, DVec3);
 impl_mat3_traits_unsafe!(f64, DMat3);
 
 mod const_test_mat3 {
diff --git a/src/mat4.rs b/src/mat4.rs
index 83d3e2e..5da58f6 100644
--- a/src/mat4.rs
+++ b/src/mat4.rs
@@ -5,7 +5,7 @@ use crate::core::{
         projection::ProjectionMatrix,
     },
 };
-use crate::{DQuat, DVec3, DVec4, EulerRot, Quat, Vec3, Vec3A, Vec4};
+use crate::{DMat3, DQuat, DVec3, DVec4, EulerRot, Mat3, Quat, Vec3, Vec3A, Vec4};
 
 #[cfg(all(
     target_feature = "sse2",
@@ -63,7 +63,7 @@ use std::iter::{Product, Sum};
 //}
 
 macro_rules! impl_mat4_methods {
-    ($t:ident, $vec4:ident, $vec3:ident, $quat:ident, $inner:ident) => {
+    ($t:ident, $vec4:ident, $vec3:ident, $mat3:ident, $quat:ident, $inner:ident) => {
         /// A 4x4 matrix with all elements set to `0.0`.
         pub const ZERO: Self = Self($inner::ZERO);
 
@@ -177,6 +177,21 @@ macro_rules! impl_mat4_methods {
             Self($inner::from_quaternion(rotation.0))
         }
 
+        /// Creates an affine transformation matrix from the given 3x3 linear transformation
+        /// matrix.
+        ///
+        /// The resulting matrix can be used to transform 3D points and vectors. See
+        /// [`Self::transform_point3()`] and [`Self::transform_vector3()`].
+        #[inline(always)]
+        pub fn from_mat3(m: $mat3) -> Self {
+            Self::from_cols(
+                (m.x_axis, 0.0).into(),
+                (m.y_axis, 0.0).into(),
+                (m.z_axis, 0.0).into(),
+                $vec4::W,
+            )
+        }
+
         /// Creates an affine transformation matrix from the given 3D `translation`.
         ///
         /// The resulting matrix can be used to transform 3D points and vectors. See
@@ -200,15 +215,6 @@ macro_rules! impl_mat4_methods {
             Self($inner::from_axis_angle(axis.0, angle))
         }
 
-        #[deprecated(
-            since = "0.15.0",
-            note = "Please use `from_euler(EulerRot::YXZ, yaw, pitch, roll)` instead"
-        )]
-        #[inline(always)]
-        pub fn from_rotation_ypr(yaw: $t, pitch: $t, roll: $t) -> Self {
-            Self::from_euler(EulerRot::YXZ, yaw, pitch, roll)
-        }
-
         #[inline(always)]
         /// Creates a affine transformation matrix containing a rotation from the given euler
         /// rotation sequence and angles (in radians).
@@ -764,7 +770,7 @@ pub struct Mat4(pub(crate) InnerF32);
 // define_mat4_struct!(Mat4, InnerF32);
 
 impl Mat4 {
-    impl_mat4_methods!(f32, Vec4, Vec3, Quat, InnerF32);
+    impl_mat4_methods!(f32, Vec4, Vec3, Mat3, Quat, InnerF32);
 
     /// Transforms the given `Vec3A` as 3D point.
     ///
@@ -833,7 +839,7 @@ pub struct DMat4(pub(crate) InnerF64);
 // define_mat4_struct!(DMat4, InnerF64);
 
 impl DMat4 {
-    impl_mat4_methods!(f64, DVec4, DVec3, DQuat, InnerF64);
+    impl_mat4_methods!(f64, DVec4, DVec3, DMat3, DQuat, InnerF64);
 
     #[inline(always)]
     pub fn as_f32(&self) -> Mat4 {
diff --git a/src/quat.rs b/src/quat.rs
index 5846055..fbb3ed1 100644
--- a/src/quat.rs
+++ b/src/quat.rs
@@ -73,12 +73,6 @@ macro_rules! impl_quat_methods {
             Self(v.0)
         }
 
-        #[deprecated(since = "0.15.2", note = "Please use `from_slice()` instead")]
-        #[inline(always)]
-        pub fn from_slice_unaligned(slice: &[$t]) -> Self {
-            Self::from_slice(slice)
-        }
-
         /// Creates a rotation quaternion from a slice.
         ///
         /// # Preconditions
@@ -96,12 +90,6 @@ macro_rules! impl_quat_methods {
             Self(q)
         }
 
-        #[deprecated(since = "0.15.2", note = "Please use `write_to_slice()` instead")]
-        #[inline(always)]
-        pub fn write_to_slice_unaligned(self, slice: &mut [$t]) {
-            self.write_to_slice(slice)
-        }
-
         /// Writes the quaternion to an unaligned slice.
         ///
         /// # Panics
@@ -155,26 +143,12 @@ macro_rules! impl_quat_methods {
             Self($inner::from_rotation_z(angle))
         }
 
-        #[deprecated(
-            since = "0.15.0",
-            note = "Please use `from_euler(EulerRot::YXZ, yaw, pitch, roll)` instead"
-        )]
-        #[inline(always)]
-        pub fn from_rotation_ypr(yaw: $t, pitch: $t, roll: $t) -> Self {
-            Self::from_euler(EulerRot::YXZ, yaw, pitch, roll)
-        }
-
         #[inline(always)]
         /// Creates a quaternion from the given euler rotation sequence and the angles (in radians).
         pub fn from_euler(euler: EulerRot, a: $t, b: $t, c: $t) -> Self {
             euler.new_quat(a, b, c)
         }
 
-        #[deprecated(since = "0.15.0", note = "Please use `from_mat3` instead")]
-        pub fn from_rotation_mat3(mat: &$mat3) -> Self {
-            Self::from_mat3(mat)
-        }
-
         /// Creates a quaternion from a 3x3 rotation matrix.
         #[inline]
         pub fn from_mat3(mat: &$mat3) -> Self {
@@ -185,11 +159,6 @@ macro_rules! impl_quat_methods {
             ))
         }
 
-        #[deprecated(since = "0.15.0", note = "Please use `from_mat4` instead")]
-        pub fn from_rotation_mat4(mat: &$mat4) -> Self {
-            Self::from_mat4(mat)
-        }
-
         /// Creates a quaternion from a 3x3 rotation matrix inside a homogeneous 4x4 matrix.
         #[inline]
         pub fn from_mat4(mat: &$mat4) -> Self {
diff --git a/src/vec.rs b/src/vec.rs
index 0c9fd72..5abb7a3 100644
--- a/src/vec.rs
+++ b/src/vec.rs
@@ -128,12 +128,6 @@ macro_rules! impl_vecn_common_methods {
             $mask(self.0.cmplt(other.0))
         }
 
-        #[deprecated(since = "0.15.2", note = "Please use `from_slice()` instead")]
-        #[inline(always)]
-        pub fn from_slice_unaligned(slice: &[$t]) -> Self {
-            Self::from_slice(slice)
-        }
-
         /// Creates a vector from the first N values in `slice`.
         ///
         /// # Panics
@@ -144,12 +138,6 @@ macro_rules! impl_vecn_common_methods {
             Self($vectrait::from_slice_unaligned(slice))
         }
 
-        #[deprecated(since = "0.15.2", note = "Please use `write_to_slice()` instead")]
-        #[inline(always)]
-        pub fn write_to_slice_unaligned(self, slice: &mut [$t]) {
-            self.write_to_slice(slice)
-        }
-
         /// Writes the elements of `self` to the first N elements in `slice`.
         ///
         /// # Panics
diff --git a/src/vec3.rs b/src/vec3.rs
index 6011761..538e43e 100644
--- a/src/vec3.rs
+++ b/src/vec3.rs
@@ -90,7 +90,7 @@ macro_rules! impl_vec3_common_methods {
 }
 
 macro_rules! impl_vec3_common_traits {
-    ($t:ty, $new:ident, $vec2:ident, $vec3:ident, $vec4:ident, $mask:ident, $inner:ident) => {
+    ($t:ty, $new:ident, $vec2:ident, $vec3:ident, $vec4:ident, $inner:ident) => {
         /// Creates a 3-dimensional vector.
         #[inline(always)]
         pub fn $new(x: $t, y: $t, z: $t) -> $vec3 {
@@ -266,8 +266,8 @@ macro_rules! impl_vec3_float_methods {
 
 // implements traits that are common between `Vec3`, `Vec3A` and `Vec4` types.
 macro_rules! impl_vec3_float_traits {
-    ($t:ty, $new:ident, $vec2:ident, $vec3:ident, $vec4:ident, $mask:ident, $inner:ident) => {
-        impl_vec3_common_traits!($t, $new, $vec2, $vec3, $vec4, $mask, $inner);
+    ($t:ty, $new:ident, $vec2:ident, $vec3:ident, $vec4:ident, $inner:ident) => {
+        impl_vec3_common_traits!($t, $new, $vec2, $vec3, $vec4, $inner);
         impl_vecn_signed_traits!($t, 3, $vec3, $inner, SignedVector3);
     };
 }
@@ -281,7 +281,7 @@ macro_rules! impl_f32_vec3 {
             impl_vecn_as_i32!(IVec3, x, y, z);
             impl_vecn_as_u32!(UVec3, x, y, z);
         }
-        impl_vec3_float_traits!(f32, $new, $vec2, $vec3, $vec4, $mask, $inner);
+        impl_vec3_float_traits!(f32, $new, $vec2, $vec3, $vec4, $inner);
     };
 }
 
@@ -342,7 +342,7 @@ impl DVec3 {
     impl_vecn_as_i32!(IVec3, x, y, z);
     impl_vecn_as_u32!(UVec3, x, y, z);
 }
-impl_vec3_float_traits!(f64, dvec3, DVec2, DVec3, DVec4, BVec3, XYZF64);
+impl_vec3_float_traits!(f64, dvec3, DVec2, DVec3, DVec4, XYZF64);
 
 type XYZI32 = XYZ<i32>;
 
@@ -358,7 +358,7 @@ impl IVec3 {
     impl_vecn_as_f64!(DVec3, x, y, z);
     impl_vecn_as_u32!(UVec3, x, y, z);
 }
-impl_vec3_common_traits!(i32, ivec3, IVec2, IVec3, IVec4, BVec3, XYZI32);
+impl_vec3_common_traits!(i32, ivec3, IVec2, IVec3, IVec4, XYZI32);
 impl_vecn_signed_traits!(i32, 3, IVec3, XYZI32, SignedVector3);
 impl_vecn_eq_hash_traits!(i32, 3, IVec3);
 
@@ -375,7 +375,7 @@ impl UVec3 {
     impl_vecn_as_f64!(DVec3, x, y, z);
     impl_vecn_as_i32!(IVec3, x, y, z);
 }
-impl_vec3_common_traits!(u32, uvec3, UVec2, UVec3, UVec4, BVec3, XYZU32);
+impl_vec3_common_traits!(u32, uvec3, UVec2, UVec3, UVec4, XYZU32);
 impl_vecn_eq_hash_traits!(u32, 3, UVec3);
 
 #[test]


Test patch:
diff --git a/tests/euler.rs b/tests/euler.rs
index 53db1f8..94e76e6 100644
--- a/tests/euler.rs
+++ b/tests/euler.rs
@@ -188,29 +188,6 @@ macro_rules! impl_all_quat_tests_two_axis {
     };
 }
 
-macro_rules! impl_ypr_test {
-    ($t:ty, $quat:ident, $euler:path) => {
-        #[test]
-        fn test_ypr() {
-            let euler = $euler;
-            for u in (-176..=176).step_by(44) {
-                for v in (-176..=176).step_by(44) {
-                    for w in (-176..=176).step_by(44) {
-                        let u1 = (u as $t).to_radians();
-                        let v1 = (v as $t).to_radians();
-                        let w1 = (w as $t).to_radians();
-
-                        let q1: $quat = $quat::from_euler(euler, u1, v1, w1);
-                        #[allow(deprecated)]
-                        let q2: $quat = $quat::from_rotation_ypr(u1, v1, w1);
-                        assert_approx_eq!(q1, q2, 1e-5);
-                    }
-                }
-            }
-        }
-    };
-}
-
 mod euler {
     use super::AngleDiff;
     use glam::*;
@@ -222,8 +199,6 @@ mod euler {
         impl_all_quat_tests_three_axis!(f32, Quat, Vec3);
 
         impl_all_quat_tests_two_axis!(f32, Quat, Vec3);
-
-        impl_ypr_test!(f32, Quat, ER::YXZ);
     }
 
     mod dquat {
@@ -232,7 +207,5 @@ mod euler {
         impl_all_quat_tests_three_axis!(f64, DQuat, DVec3);
 
         impl_all_quat_tests_two_axis!(f64, DQuat, DVec3);
-
-        impl_ypr_test!(f64, DQuat, ER::YXZ);
     }
 }
diff --git a/tests/mat2.rs b/tests/mat2.rs
index 6608451..026e27e 100644
--- a/tests/mat2.rs
+++ b/tests/mat2.rs
@@ -105,7 +105,7 @@ macro_rules! impl_mat2_tests {
         fn test_from_mat3() {
             let m3 =
                 $mat3::from_cols_array_2d(&[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]);
-            let m2 = $mat2::from(m3);
+            let m2 = $mat2::from_mat3(m3);
             assert_eq!($mat2::from_cols_array_2d(&[[1.0, 2.0], [4.0, 5.0]]), m2);
         }
 
diff --git a/tests/mat3.rs b/tests/mat3.rs
index 86f9fc0..c7423da 100644
--- a/tests/mat3.rs
+++ b/tests/mat3.rs
@@ -2,7 +2,7 @@
 mod support;
 
 macro_rules! impl_mat3_tests {
-    ($t:ident, $const_new:ident, $newmat3:ident, $mat3:ident, $mat4:ident, $quat:ident, $newvec3:ident, $vec3:ident, $vec2:ident) => {
+    ($t:ident, $const_new:ident, $newmat3:ident, $mat3:ident, $mat2:ident, $mat4:ident, $quat:ident, $newvec3:ident, $vec3:ident, $vec2:ident) => {
         use core::$t::INFINITY;
         use core::$t::NAN;
         use core::$t::NEG_INFINITY;
@@ -211,6 +211,15 @@ macro_rules! impl_mat3_tests {
             assert_approx_eq!($newvec3(0.0, 0.0, 8.0), m.z_axis);
         }
 
+        #[test]
+        fn test_from_mat2() {
+            let m2 = $mat2::from_cols_array_2d(&[[1.0, 2.0], [3.0, 4.0]]);
+            let m3 = $mat3::from_mat2(m2);
+            assert_eq!(
+                $mat3::from_cols_array_2d(&[[1.0, 2.0, 0.0], [3.0, 4.0, 0.0], [0.0, 0.0, 1.0]]),
+                m3
+            );
+        }
         #[test]
         fn test_from_mat4() {
             let m4 = $mat4::from_cols_array_2d(&[
@@ -219,7 +228,7 @@ macro_rules! impl_mat3_tests {
                 [9.0, 10.0, 11.0, 12.0],
                 [13.0, 14.0, 15.0, 16.0],
             ]);
-            let m3 = $mat3::from(m4);
+            let m3 = $mat3::from_mat4(m4);
             assert_eq!(
                 $mat3::from_cols_array_2d(&[[1.0, 2.0, 3.0], [5.0, 6.0, 7.0], [9.0, 10.0, 11.0]]),
                 m3
@@ -361,7 +370,9 @@ macro_rules! impl_mat3_tests {
 
 mod mat3 {
     use super::support::deg;
-    use glam::{const_mat3, mat3, swizzles::*, vec3, vec3a, Mat3, Mat4, Quat, Vec2, Vec3, Vec3A};
+    use glam::{
+        const_mat3, mat3, swizzles::*, vec3, vec3a, Mat2, Mat3, Mat4, Quat, Vec2, Vec3, Vec3A,
+    };
 
     #[test]
     fn test_align() {
@@ -390,12 +401,14 @@ mod mat3 {
         );
     }
 
-    impl_mat3_tests!(f32, const_mat3, mat3, Mat3, Mat4, Quat, vec3, Vec3, Vec2);
+    impl_mat3_tests!(f32, const_mat3, mat3, Mat3, Mat2, Mat4, Quat, vec3, Vec3, Vec2);
 }
 
 mod mat3a {
     use super::support::deg;
-    use glam::{const_mat3a, mat3a, swizzles::*, vec3a, Mat3A, Mat4, Quat, Vec2, Vec3, Vec3A};
+    use glam::{
+        const_mat3a, mat3a, swizzles::*, vec3a, Mat2, Mat3A, Mat4, Quat, Vec2, Vec3, Vec3A,
+    };
 
     #[test]
     fn test_align() {
@@ -425,6 +438,7 @@ mod mat3a {
         const_mat3a,
         mat3a,
         Mat3A,
+        Mat2,
         Mat4,
         Quat,
         vec3a,
@@ -435,7 +449,7 @@ mod mat3a {
 
 mod dmat3 {
     use super::support::deg;
-    use glam::{const_dmat3, dmat3, dvec3, swizzles::*, DMat3, DMat4, DQuat, DVec2, DVec3};
+    use glam::{const_dmat3, dmat3, dvec3, swizzles::*, DMat2, DMat3, DMat4, DQuat, DVec2, DVec3};
 
     #[test]
     fn test_align() {
@@ -449,6 +463,7 @@ mod dmat3 {
         const_dmat3,
         dmat3,
         DMat3,
+        DMat2,
         DMat4,
         DQuat,
         dvec3,
diff --git a/tests/mat4.rs b/tests/mat4.rs
index f35edb2..510b573 100644
--- a/tests/mat4.rs
+++ b/tests/mat4.rs
@@ -2,7 +2,7 @@
 mod support;
 
 macro_rules! impl_mat4_tests {
-    ($t:ident, $const_new:ident, $newmat4:ident, $newvec4:ident, $newvec3:ident, $mat4:ident, $quat:ident, $vec4:ident, $vec3:ident) => {
+    ($t:ident, $const_new:ident, $newmat4:ident, $newvec4:ident, $newvec3:ident, $mat4:ident, $mat3:ident, $quat:ident, $vec4:ident, $vec3:ident) => {
         use core::$t::INFINITY;
         use core::$t::NAN;
         use core::$t::NEG_INFINITY;
@@ -185,6 +185,22 @@ macro_rules! impl_mat4_tests {
             should_glam_assert!({ $mat4::from_quat($quat::from_xyzw(0.0, 0.0, 0.0, 0.0)) });
         }
 
+        #[test]
+        fn test_from_mat3() {
+            let m3 =
+                $mat3::from_cols_array_2d(&[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]);
+            let m4 = $mat4::from_mat3(m3);
+            assert_eq!(
+                $mat4::from_cols_array_2d(&[
+                    [1.0, 2.0, 3.0, 0.0],
+                    [4.0, 5.0, 6.0, 0.0],
+                    [7.0, 8.0, 9.0, 0.0],
+                    [0.0, 0.0, 0.0, 1.0]
+                ]),
+                m4
+            );
+        }
+
         #[test]
         fn test_mat4_mul() {
             let m = $mat4::from_axis_angle($vec3::Z, deg(90.0));
@@ -671,7 +687,7 @@ macro_rules! impl_mat4_tests {
 
 mod mat4 {
     use super::support::deg;
-    use glam::{const_mat4, mat4, swizzles::*, vec3, vec4, Mat4, Quat, Vec3, Vec4};
+    use glam::{const_mat4, mat4, swizzles::*, vec3, vec4, Mat3, Mat4, Quat, Vec3, Vec4};
 
     #[test]
     fn test_align() {
@@ -719,12 +735,12 @@ mod mat4 {
         );
     }
 
-    impl_mat4_tests!(f32, const_mat4, mat4, vec4, vec3, Mat4, Quat, Vec4, Vec3);
+    impl_mat4_tests!(f32, const_mat4, mat4, vec4, vec3, Mat4, Mat3, Quat, Vec4, Vec3);
 }
 
 mod dmat4 {
     use super::support::deg;
-    use glam::{const_dmat4, dmat4, dvec3, dvec4, swizzles::*, DMat4, DQuat, DVec3, DVec4};
+    use glam::{const_dmat4, dmat4, dvec3, dvec4, swizzles::*, DMat3, DMat4, DQuat, DVec3, DVec4};
 
     #[test]
     fn test_align() {
@@ -740,6 +756,7 @@ mod dmat4 {
         dvec4,
         dvec3,
         DMat4,
+        DMat3,
         DQuat,
         DVec4,
         DVec3