Add identity and zero static methods to Quat's impl

This commit is contained in:
Brendan Zabarauskas 2012-12-14 16:04:46 +10:00
parent 5ce765367a
commit 889736bd61

View file

@ -242,6 +242,32 @@ pub impl<T:Copy Float> Quat<T> {
let half = theta.to_radians() / Number::from(2);
Quat::from_sv(cos(&half), axis.mul_t(sin(&half)))
}
/**
* # Return value
*
* The multiplicative identity, ie: `q = 1 + 0i + 0j + 0i`
*/
#[inline(always)]
static pure fn identity() -> Quat<T> {
Quat::new(Number::one(),
Number::zero(),
Number::zero(),
Number::zero())
}
/**
* # Return value
*
* The additive identity, ie: `q = 0 + 0i + 0j + 0i`
*/
#[inline(always)]
static pure fn zero() -> Quat<T> {
Quat::new(Number::zero(),
Number::zero(),
Number::zero(),
Number::zero())
}
}
pub impl<T:Copy> Quat<T>: Index<uint, T> {