Skip to main content

dynamics_spatial/
so3.rs

1//! Defines **special orthogonal group** SO(3) and related operations.
2
3use crate::vector3d::Vector3D;
4use nalgebra::Matrix3;
5
6pub struct SO3(pub(crate) Matrix3<f64>);
7
8impl SO3 {
9    /// Returns the identity rotation.
10    #[must_use]
11    pub fn identity() -> Self {
12        Self(Matrix3::identity())
13    }
14
15    #[must_use]
16    pub fn from_vector3d(vec: &Vector3D) -> Self {
17        let v = vec.as_slice();
18        Self(Matrix3::new(
19            0.0, -v[2], v[1], v[2], 0.0, -v[0], -v[1], v[0], 0.0,
20        ))
21    }
22}