Formatting

This commit is contained in:
Brendan Zabarauskas 2012-11-29 11:17:36 +10:00
parent 26a22e0cc7
commit 64761478dd

View file

@ -26,6 +26,10 @@ pub trait Angle<T>: Add<self,self>
pure fn wrap() -> self;
}
pub enum Radians<T> = T;
pub impl<T:Copy Num NumCast> Radians<T>: Angle<T> {
@ -43,27 +47,45 @@ pub impl<T:Copy Num NumCast> Radians<T>: Angle<T> {
}
pub impl<T:Copy Num> Radians<T>: Add<Radians<T>, Radians<T>> {
#[inline(always)] pure fn add(rhs: &Radians<T>) -> Radians<T> { Radians(*self + **rhs) }
#[inline(always)]
pure fn add(rhs: &Radians<T>) -> Radians<T> {
Radians(*self + **rhs)
}
}
pub impl<T:Copy Num> Radians<T>: Sub<Radians<T>, Radians<T>> {
#[inline(always)] pure fn sub(rhs: &Radians<T>) -> Radians<T> { Radians(*self - **rhs) }
#[inline(always)]
pure fn sub(rhs: &Radians<T>) -> Radians<T> {
Radians(*self - **rhs)
}
}
pub impl<T:Copy Num> Radians<T>: Mul<T, Radians<T>> {
#[inline(always)] pure fn mul(rhs: &T) -> Radians<T> { Radians(*self * *rhs) }
#[inline(always)]
pure fn mul(rhs: &T) -> Radians<T> {
Radians(*self * *rhs)
}
}
pub impl<T:Copy Num> Radians<T>: Div<T, Radians<T>> {
#[inline(always)] pure fn div(rhs: &T) -> Radians<T> { Radians(*self / *rhs) }
#[inline(always)]
pure fn div(rhs: &T) -> Radians<T> {
Radians(*self / *rhs)
}
}
pub impl<T:Copy Num> Radians<T>: Modulo<T, Radians<T>> {
#[inline(always)] pure fn modulo(rhs: &T) -> Radians<T> { Radians(*self % *rhs) }
#[inline(always)]
pure fn modulo(rhs: &T) -> Radians<T> {
Radians(*self % *rhs)
}
}
pub impl<T:Copy Num> Radians<T>: Neg<Radians<T>> {
#[inline(always)] pure fn neg() -> Radians<T> { Radians(-*self) }
#[inline(always)]
pure fn neg() -> Radians<T> {
Radians(-*self)
}
}
pub impl<T:Copy Eq> Radians<T>: Eq {
@ -78,6 +100,10 @@ pub impl<T:Copy Ord> Radians<T>: Ord {
#[inline(always)] pure fn gt(other: &Radians<T>) -> bool { *self > **other }
}
pub enum Degrees<T> = T;
pub impl<T:Copy Num NumCast> Degrees<T>: Angle<T> {
@ -95,27 +121,41 @@ pub impl<T:Copy Num NumCast> Degrees<T>: Angle<T> {
}
pub impl<T:Copy Num> Degrees<T>: Add<Degrees<T>, Degrees<T>> {
#[inline(always)] pure fn add(rhs: &Degrees<T>) -> Degrees<T> { Degrees(*self + **rhs) }
#[inline(always)]
pure fn add(rhs: &Degrees<T>) -> Degrees<T> {
Degrees(*self + **rhs)
}
}
pub impl<T:Copy Num> Degrees<T>: Sub<Degrees<T>, Degrees<T>> {
#[inline(always)] pure fn sub(rhs: &Degrees<T>) -> Degrees<T> { Degrees(*self - **rhs) }
#[inline(always)]
pure fn sub(rhs: &Degrees<T>) -> Degrees<T> {
Degrees(*self - **rhs)
}
}
pub impl<T:Copy Num> Degrees<T>: Mul<T, Degrees<T>> {
#[inline(always)] pure fn mul(rhs: &T) -> Degrees<T> { Degrees(*self * *rhs) }
#[inline(always)] pure fn mul(rhs: &T) -> Degrees<T> {
Degrees(*self * *rhs)
}
}
pub impl<T:Copy Num> Degrees<T>: Div<T, Degrees<T>> {
#[inline(always)] pure fn div(rhs: &T) -> Degrees<T> { Degrees(*self / *rhs) }
#[inline(always)] pure fn div(rhs: &T) -> Degrees<T> {
Degrees(*self / *rhs)
}
}
pub impl<T:Copy Num> Degrees<T>: Modulo<T, Degrees<T>> {
#[inline(always)] pure fn modulo(rhs: &T) -> Degrees<T> { Degrees(*self % *rhs) }
#[inline(always)] pure fn modulo(rhs: &T) -> Degrees<T> {
Degrees(*self % *rhs)
}
}
pub impl<T:Copy Num> Degrees<T>: Neg<Degrees<T>> {
#[inline(always)] pure fn neg() -> Degrees<T> { Degrees(-*self) }
#[inline(always)] pure fn neg() -> Degrees<T> {
Degrees(-*self)
}
}
pub impl<T:Copy Eq> Degrees<T>: Eq {
@ -130,6 +170,10 @@ pub impl<T:Copy Ord> Degrees<T>: Ord {
#[inline(always)] pure fn gt(other: &Degrees<T>) -> bool { *self > **other }
}
/**
* An angular rotation around an arbitary axis
*/
@ -173,6 +217,10 @@ pub impl<T:Copy Num NumCast> Rotation<T> {
}
}
pub struct Euler<T> {
x: Radians<T>, // pitch
y: Radians<T>, // yaw