From 64761478ddd9fd269c8c661c20761fae3d0b2353 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Thu, 29 Nov 2012 11:17:36 +1000 Subject: [PATCH] Formatting --- src/angle.rs | 74 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 13 deletions(-) diff --git a/src/angle.rs b/src/angle.rs index 3487f61..1ed9a63 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -26,6 +26,10 @@ pub trait Angle: Add pure fn wrap() -> self; } + + + + pub enum Radians = T; pub impl Radians: Angle { @@ -43,27 +47,45 @@ pub impl Radians: Angle { } pub impl Radians: Add, Radians> { - #[inline(always)] pure fn add(rhs: &Radians) -> Radians { Radians(*self + **rhs) } + #[inline(always)] + pure fn add(rhs: &Radians) -> Radians { + Radians(*self + **rhs) + } } pub impl Radians: Sub, Radians> { - #[inline(always)] pure fn sub(rhs: &Radians) -> Radians { Radians(*self - **rhs) } + #[inline(always)] + pure fn sub(rhs: &Radians) -> Radians { + Radians(*self - **rhs) + } } pub impl Radians: Mul> { - #[inline(always)] pure fn mul(rhs: &T) -> Radians { Radians(*self * *rhs) } + #[inline(always)] + pure fn mul(rhs: &T) -> Radians { + Radians(*self * *rhs) + } } pub impl Radians: Div> { - #[inline(always)] pure fn div(rhs: &T) -> Radians { Radians(*self / *rhs) } + #[inline(always)] + pure fn div(rhs: &T) -> Radians { + Radians(*self / *rhs) + } } pub impl Radians: Modulo> { - #[inline(always)] pure fn modulo(rhs: &T) -> Radians { Radians(*self % *rhs) } + #[inline(always)] + pure fn modulo(rhs: &T) -> Radians { + Radians(*self % *rhs) + } } pub impl Radians: Neg> { - #[inline(always)] pure fn neg() -> Radians { Radians(-*self) } + #[inline(always)] + pure fn neg() -> Radians { + Radians(-*self) + } } pub impl Radians: Eq { @@ -78,6 +100,10 @@ pub impl Radians: Ord { #[inline(always)] pure fn gt(other: &Radians) -> bool { *self > **other } } + + + + pub enum Degrees = T; pub impl Degrees: Angle { @@ -93,29 +119,43 @@ pub impl Degrees: Angle { self % cast(360) // TODO: keep in the domain of 0 to 360 } } - + pub impl Degrees: Add, Degrees> { - #[inline(always)] pure fn add(rhs: &Degrees) -> Degrees { Degrees(*self + **rhs) } + #[inline(always)] + pure fn add(rhs: &Degrees) -> Degrees { + Degrees(*self + **rhs) + } } pub impl Degrees: Sub, Degrees> { - #[inline(always)] pure fn sub(rhs: &Degrees) -> Degrees { Degrees(*self - **rhs) } + #[inline(always)] + pure fn sub(rhs: &Degrees) -> Degrees { + Degrees(*self - **rhs) + } } pub impl Degrees: Mul> { - #[inline(always)] pure fn mul(rhs: &T) -> Degrees { Degrees(*self * *rhs) } + #[inline(always)] pure fn mul(rhs: &T) -> Degrees { + Degrees(*self * *rhs) + } } pub impl Degrees: Div> { - #[inline(always)] pure fn div(rhs: &T) -> Degrees { Degrees(*self / *rhs) } + #[inline(always)] pure fn div(rhs: &T) -> Degrees { + Degrees(*self / *rhs) + } } pub impl Degrees: Modulo> { - #[inline(always)] pure fn modulo(rhs: &T) -> Degrees { Degrees(*self % *rhs) } + #[inline(always)] pure fn modulo(rhs: &T) -> Degrees { + Degrees(*self % *rhs) + } } pub impl Degrees: Neg> { - #[inline(always)] pure fn neg() -> Degrees { Degrees(-*self) } + #[inline(always)] pure fn neg() -> Degrees { + Degrees(-*self) + } } pub impl Degrees: Eq { @@ -130,6 +170,10 @@ pub impl Degrees: Ord { #[inline(always)] pure fn gt(other: &Degrees) -> bool { *self > **other } } + + + + /** * An angular rotation around an arbitary axis */ @@ -173,6 +217,10 @@ pub impl Rotation { } } + + + + pub struct Euler { x: Radians, // pitch y: Radians, // yaw