use crate::util::Basis;

use super::Vector3D;

pub type BasisD = Basis<f64>;

impl BasisD {
    pub fn from_euler(yaw: f64, pitch: f64, roll: f64) -> Self {
        let basis = Self::identity();
        let basis = basis.rotate_by_axis(&basis.y, yaw);
        let basis = basis.rotate_by_axis(&basis.x, pitch);
        basis.rotate_by_axis(&basis.z, roll)
    }

    pub fn rotate_by_axis(&self, axis: &Vector3D, angle: f64) -> Self {
        Self {
            x: self.x.rotate_around_axis(axis, angle),
            y: self.y.rotate_around_axis(axis, angle),
            z: self.z.rotate_around_axis(axis, angle),
        }
    }
}
