1use crate::{components, datatypes};
2
3#[derive(Clone, Debug, Copy, PartialEq)]
7pub enum Rotation3D {
8 Quaternion(components::RotationQuat),
10
11 AxisAngle(components::RotationAxisAngle),
13}
14
15impl Rotation3D {
16 pub const IDENTITY: Self = Self::Quaternion(components::RotationQuat::IDENTITY);
18}
19
20impl From<components::RotationQuat> for Rotation3D {
21 #[inline]
22 fn from(quat: components::RotationQuat) -> Self {
23 Self::Quaternion(quat)
24 }
25}
26
27impl From<datatypes::Quaternion> for Rotation3D {
28 #[inline]
29 fn from(quat: datatypes::Quaternion) -> Self {
30 Self::Quaternion(quat.into())
31 }
32}
33
34#[cfg(feature = "glam")]
35impl From<glam::Quat> for Rotation3D {
36 #[inline]
37 fn from(quat: glam::Quat) -> Self {
38 Self::Quaternion(quat.into())
39 }
40}
41
42impl From<components::RotationAxisAngle> for Rotation3D {
43 #[inline]
44 fn from(axis_angle: components::RotationAxisAngle) -> Self {
45 Self::AxisAngle(axis_angle)
46 }
47}
48
49impl From<datatypes::RotationAxisAngle> for Rotation3D {
50 #[inline]
51 fn from(axis_angle: datatypes::RotationAxisAngle) -> Self {
52 Self::AxisAngle(axis_angle.into())
53 }
54}