use num::cast::*; use vec::Vec3; pub enum Angle { degrees(T), radians(T), } pub impl Angle { pure fn degrees() -> T { match self { degrees(theta) => theta, radians(theta) => theta * cast(180f64 / f64::consts::pi) } } pure fn radians() -> T { match self { degrees(theta) => theta * cast(f64::consts::pi / 180f64), radians(theta) => theta } } } pub impl Angle: Add> { #[inline(always)] pure fn add(rhs: &T) -> Angle { match self { degrees(theta) => degrees(theta + *rhs), radians(theta) => radians(theta + *rhs) } } } pub impl Angle: Sub> { #[inline(always)] pure fn sub(rhs: &T) -> Angle { match self { degrees(theta) => degrees(theta - *rhs), radians(theta) => radians(theta - *rhs) } } } pub impl Angle: Mul> { #[inline(always)] pure fn mul(rhs: &T) -> Angle { match self { degrees(theta) => degrees(theta * *rhs), radians(theta) => radians(theta * *rhs) } } } pub impl Angle: Div> { #[inline(always)] pure fn div(rhs: &T) -> Angle { match self { degrees(theta) => degrees(theta / *rhs), radians(theta) => radians(theta / *rhs) } } } pub impl Angle: Modulo> { #[inline(always)] pure fn modulo(rhs: &T) -> Angle { match self { degrees(theta) => degrees(theta % *rhs), radians(theta) => radians(theta % *rhs) } } } pub impl Angle: Neg> { #[inline(always)] pure fn neg() -> Angle { match self { degrees(theta) => degrees(-theta), radians(theta) => radians(-theta) } } } pub struct AxisRotation { axis: Vec3, theta: Angle, } pub struct Euler { x: T, // pitch y: T, // yaw z: T, // roll }