use core::fmt;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct Quaternion<T> {
w: T,
x: T,
y: T,
z: T,
}
impl<T> Quaternion<T> {
pub const fn new(w: T, x: T, y: T, z: T) -> Self {
Self { w, x, y, z }
}
pub const fn w(&self) -> &T {
&self.w
}
pub const fn x(&self) -> &T {
&self.x
}
pub const fn y(&self) -> &T {
&self.y
}
pub const fn z(&self) -> &T {
&self.z
}
}
impl<T: fmt::Display> fmt::Display for Quaternion<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} + {}i + {}j + {}k", self.w, self.x, self.y, self.z)
}
}