1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use crate::datatypes::Quaternion;

use super::Rotation3D;

impl Rotation3D {
    /// The identity rotation, representing no rotation.
    pub const IDENTITY: Rotation3D = Rotation3D::Quaternion(Quaternion::IDENTITY);
}

impl From<Quaternion> for Rotation3D {
    #[inline]
    fn from(q: Quaternion) -> Self {
        Self::Quaternion(q)
    }
}

impl From<crate::datatypes::RotationAxisAngle> for Rotation3D {
    #[inline]
    fn from(r: crate::datatypes::RotationAxisAngle) -> Self {
        Self::AxisAngle(r)
    }
}

#[cfg(feature = "glam")]
impl From<Rotation3D> for glam::Quat {
    #[inline]
    fn from(val: Rotation3D) -> Self {
        match val {
            Rotation3D::Quaternion(v) => v.into(),
            Rotation3D::AxisAngle(a) => a.into(),
        }
    }
}

#[cfg(feature = "glam")]
impl From<glam::Quat> for Rotation3D {
    #[inline]
    fn from(val: glam::Quat) -> Self {
        Rotation3D::Quaternion(val.into())
    }
}

#[cfg(feature = "mint")]
impl From<Rotation3D> for mint::Quaternion<f32> {
    #[inline]
    fn from(val: Rotation3D) -> Self {
        match val {
            Rotation3D::Quaternion(v) => v.into(),
            Rotation3D::AxisAngle(a) => a.into(),
        }
    }
}

#[cfg(feature = "mint")]
impl From<mint::Quaternion<f32>> for Rotation3D {
    #[inline]
    fn from(val: mint::Quaternion<f32>) -> Self {
        Rotation3D::Quaternion(val.into())
    }
}