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