diff --git a/src/angle.rs b/src/angle.rs index cfa6c13..869a6fc 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -1,3 +1,4 @@ +use core::cmp::{Eq, Ord}; use core::f64::consts::pi; use num::cast::*; use vec::Vec3; @@ -7,7 +8,8 @@ pub trait Angle: Add , Mul , Div , Modulo - , Neg { + , Neg + , Eq, Ord { pure fn to_radians() -> Radians; pure fn to_degrees() -> Degrees; } @@ -26,6 +28,18 @@ pub impl Radians: Angle { #[inline(always)] pure fn neg() -> Radians { Radians(-*self) } } +pub impl Radians: Eq { + #[inline(always)] pure fn eq(other: &Radians) -> bool { *self == **other } + #[inline(always)] pure fn ne(other: &Radians) -> bool { *self != **other } +} + +pub impl Radians: Ord { + #[inline(always)] pure fn lt(other: &Radians) -> bool { *self < **other } + #[inline(always)] pure fn le(other: &Radians) -> bool { *self <= **other } + #[inline(always)] pure fn ge(other: &Radians) -> bool { *self >= **other } + #[inline(always)] pure fn gt(other: &Radians) -> bool { *self > **other } +} + pub enum Degrees = T; pub impl Degrees: Angle { @@ -40,6 +54,18 @@ pub impl Degrees: Angle { #[inline(always)] pure fn neg() -> Degrees { Degrees(-*self) } } +pub impl Degrees: Eq { + #[inline(always)] pure fn eq(other: &Degrees) -> bool { *self == **other } + #[inline(always)] pure fn ne(other: &Degrees) -> bool { *self != **other } +} + +pub impl Degrees: Ord { + #[inline(always)] pure fn lt(other: &Degrees) -> bool { *self < **other } + #[inline(always)] pure fn le(other: &Degrees) -> bool { *self <= **other } + #[inline(always)] pure fn ge(other: &Degrees) -> bool { *self >= **other } + #[inline(always)] pure fn gt(other: &Degrees) -> bool { *self > **other } +} + pub struct AxialRotation { axis: Vec3, theta: Radians,