Add identity and zero static methods to Quat's impl
This commit is contained in:
parent
5ce765367a
commit
889736bd61
1 changed files with 26 additions and 0 deletions
26
src/quat.rs
26
src/quat.rs
|
@ -242,6 +242,32 @@ pub impl<T:Copy Float> Quat<T> {
|
||||||
let half = theta.to_radians() / Number::from(2);
|
let half = theta.to_radians() / Number::from(2);
|
||||||
Quat::from_sv(cos(&half), axis.mul_t(sin(&half)))
|
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> {
|
pub impl<T:Copy> Quat<T>: Index<uint, T> {
|
||||||
|
|
Loading…
Reference in a new issue