Simplify length2 method

This commit is contained in:
Brendan Zabarauskas 2012-11-14 14:42:40 +10:00
parent 342817610d
commit b860a63cbc

View file

@ -177,8 +177,7 @@ pub impl<T:Copy Num> Vec2<T>: NumericVector<T> {
pub impl<T:Copy Num NumCast Exp> Vec2<T>: GeometricVector<T> { pub impl<T:Copy Num NumCast Exp> Vec2<T>: GeometricVector<T> {
#[inline(always)] #[inline(always)]
pure fn length2() -> T { pure fn length2() -> T {
self[0] * self[0] + self.dot(&self)
self[1] * self[1]
} }
#[inline(always)] #[inline(always)]
@ -368,9 +367,7 @@ pub impl<T:Copy Num> Vec3<T>: NumericVector<T> {
pub impl<T:Copy Num NumCast Exp> Vec3<T>: GeometricVector<T> { pub impl<T:Copy Num NumCast Exp> Vec3<T>: GeometricVector<T> {
#[inline(always)] #[inline(always)]
pure fn length2() -> T { pure fn length2() -> T {
self[0] * self[0] + self.dot(&self)
self[1] * self[1] +
self[2] * self[2]
} }
#[inline(always)] #[inline(always)]
@ -565,10 +562,7 @@ pub impl<T:Copy Num> Vec4<T>: NumericVector<T> {
pub impl<T:Copy Num NumCast Exp> Vec4<T>: GeometricVector<T> { pub impl<T:Copy Num NumCast Exp> Vec4<T>: GeometricVector<T> {
#[inline(always)] #[inline(always)]
pure fn length2() -> T { pure fn length2() -> T {
self[0] * self[0] + self.dot(&self)
self[1] * self[1] +
self[2] * self[2] +
self[3] * self[3]
} }
#[inline(always)] #[inline(always)]