diff --git a/src/angle.rs b/src/angle.rs index ce3c4bb..c4a0f93 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -22,6 +22,7 @@ pub trait Angle: Add static pure fn quadrant() -> self; static pure fn sextant() -> self; static pure fn octant() -> self; + static pure fn zero() -> self; pure fn to_radians(&self) -> Radians; pure fn to_degrees(&self) -> Degrees; @@ -37,11 +38,12 @@ pub enum Radians = T; // FIXME: not sure why I need the Eq and Ord trait bounds, but Rust complains if I don't include them pub impl Radians: Angle { - #[inline(always)] static pure fn full_turn() -> Radians { Radians(move cast(2.0 * pi)) } // TODO: calculate absolute values - #[inline(always)] static pure fn half_turn() -> Radians { Radians(move cast(pi)) } - #[inline(always)] static pure fn quadrant() -> Radians { Radians(move cast(pi / 2.0)) } - #[inline(always)] static pure fn sextant() -> Radians { Radians(move cast(pi / 3.0)) } - #[inline(always)] static pure fn octant() -> Radians { Radians(move cast(pi / 4.0)) } + #[inline(always)] static pure fn full_turn() -> Radians { Radians(cast(2.0 * pi)) } // TODO: calculate absolute values + #[inline(always)] static pure fn half_turn() -> Radians { Radians(cast(pi)) } + #[inline(always)] static pure fn quadrant() -> Radians { Radians(cast(pi / 2.0)) } + #[inline(always)] static pure fn sextant() -> Radians { Radians(cast(pi / 3.0)) } + #[inline(always)] static pure fn octant() -> Radians { Radians(cast(pi / 4.0)) } + #[inline(always)] static pure fn zero() -> Radians { Radians(cast(0.0)) } #[inline(always)] pure fn to_radians(&self) -> Radians { *self } #[inline(always)] pure fn to_degrees(&self) -> Degrees { Degrees(**self * cast(180.0 / pi)) } @@ -123,11 +125,12 @@ pub enum Degrees = T; // FIXME: not sure why I need the Eq and Ord trait bounds, but Rust complains if I don't include them pub impl Degrees: Angle { - #[inline(always)] static pure fn full_turn() -> Degrees { Degrees(move cast(360.0)) } - #[inline(always)] static pure fn half_turn() -> Degrees { Degrees(move cast(180.0)) } - #[inline(always)] static pure fn quadrant() -> Degrees { Degrees(move cast(90.0)) } - #[inline(always)] static pure fn sextant() -> Degrees { Degrees(move cast(60.0)) } - #[inline(always)] static pure fn octant() -> Degrees { Degrees(move cast(45.0)) } + #[inline(always)] static pure fn full_turn() -> Degrees { Degrees(cast(360.0)) } + #[inline(always)] static pure fn half_turn() -> Degrees { Degrees(cast(180.0)) } + #[inline(always)] static pure fn quadrant() -> Degrees { Degrees(cast(90.0)) } + #[inline(always)] static pure fn sextant() -> Degrees { Degrees(cast(60.0)) } + #[inline(always)] static pure fn octant() -> Degrees { Degrees(cast(45.0)) } + #[inline(always)] static pure fn zero() -> Degrees { Degrees(cast(0.0)) } #[inline(always)] pure fn to_radians(&self) -> Radians { Radians(**self * cast(pi / 180.0)) } #[inline(always)] pure fn to_degrees(&self) -> Degrees { *self }