use core::fmt::Debug;
use glam::{Quat, Vec3};
use std::marker::PhantomData;
use crate::handedness::Handedness;
#[derive(Clone, Copy, Debug)]
pub struct Transform<H: Handedness> {
pub position: Vec3,
pub rotation: Quat,
pub phantom: PhantomData<H>,
}
impl<H: Handedness> Transform<H> {
pub fn from_position_rotation(position: Vec3, rotation: Quat) -> Self {
Self {
position,
rotation,
phantom: PhantomData,
}
}
pub fn into_position_rotation(self) -> (Vec3, Quat) {
(self.position, self.rotation)
}
pub fn right(&self) -> Vec3 {
self.rotation * Vec3::X
}
pub fn up(&self) -> Vec3 {
self.rotation * Vec3::Y
}
pub fn forward(&self) -> Vec3 {
self.rotation * H::FORWARD
}
pub const IDENTITY: Transform<H> = Transform {
position: Vec3::ZERO,
rotation: Quat::IDENTITY,
phantom: PhantomData,
};
}