|
1 | 1 | use super::{Basis, IsEqualApprox, Vector3}; |
2 | | -use glam::{Mat3, EulerRot}; |
| 2 | +use glam::EulerRot; |
3 | 3 | use std::ops::Mul; |
4 | 4 |
|
5 | 5 | #[derive(Copy, Clone, Debug, PartialEq)] |
@@ -68,14 +68,7 @@ impl Quat { |
68 | 68 | /// the rotation angles in the format (X angle, Y angle, Z angle). |
69 | 69 | #[inline] |
70 | 70 | pub fn to_euler(self) -> Vector3 { |
71 | | - let basis = Mat3::from_quat(self.glam()); |
72 | | - let basis = basis.to_cols_array_2d(); |
73 | | - let basis = [ |
74 | | - Vector3::new(basis[0][0], basis[1][0], basis[2][0]), |
75 | | - Vector3::new(basis[0][1], basis[1][1], basis[2][1]), |
76 | | - Vector3::new(basis[0][2], basis[1][2], basis[2][2]), |
77 | | - ]; |
78 | | - Basis::from_elements(basis).to_euler() |
| 71 | + Basis::from_quat(self).to_euler() |
79 | 72 | } |
80 | 73 |
|
81 | 74 | /// Returns the inverse of the quaternion. |
@@ -159,13 +152,12 @@ impl Quat { |
159 | 152 | } |
160 | 153 |
|
161 | 154 | #[inline] |
162 | | - fn gd(quat: glam::Quat) -> Self { |
| 155 | + pub(super) fn gd(quat: glam::Quat) -> Self { |
163 | 156 | Self::new(quat.x, quat.y, quat.z, quat.w) |
164 | 157 | } |
165 | 158 |
|
166 | 159 | #[inline] |
167 | | - #[allow(unused)] |
168 | | - fn glam(self) -> glam::Quat { |
| 160 | + pub(super) fn glam(self) -> glam::Quat { |
169 | 161 | glam::Quat::from_xyzw(self.x, self.y, self.z, self.w) |
170 | 162 | } |
171 | 163 | } |
@@ -199,13 +191,7 @@ mod test { |
199 | 191 | Vector3::new(0.136732, -0.959216, -0.247404), |
200 | 192 | Vector3::new(-0.837788, -0.245243, 0.487819), |
201 | 193 | ]); |
202 | | - let basis = Mat3::from_quat(quat.glam()).to_cols_array_2d(); |
203 | | - let basis = [ |
204 | | - Vector3::new(basis[0][0], basis[1][0], basis[2][0]), |
205 | | - Vector3::new(basis[0][1], basis[1][1], basis[2][1]), |
206 | | - Vector3::new(basis[0][2], basis[1][2], basis[2][2]), |
207 | | - ]; |
208 | | - let basis = Basis::from_elements(basis); |
| 194 | + let basis = Basis::from_quat(quat); |
209 | 195 | assert!(basis.is_equal_approx(&expect)); |
210 | 196 | } |
211 | 197 |
|
|
0 commit comments