Made usages of Number::one and Number::zero prettier

This commit is contained in:
Brendan Zabarauskas 2012-12-30 15:26:01 +10:00
parent a8da96eda4
commit 73548ab1cb
7 changed files with 116 additions and 177 deletions

View file

@ -7,7 +7,7 @@ use std::cmp::FuzzyEq;
use numeric::funs::*;
use numeric::types::angle::Angle;
use numeric::types::float::Float;
use numeric::types::number::Number;
use numeric::types::number::Number::{one, zero};
use vec::Vec2;
@ -93,9 +93,8 @@ pub impl<T:Copy Float> Mat2<T> {
*/
#[inline(always)]
static pure fn from_value(value: T) -> Mat2<T> {
let _0 = Number::from(0);
Mat2::new(value, _0,
_0, value)
Mat2::new(value, zero(),
zero(), value)
}
// FIXME: An interim solution to the issues with static functions
@ -140,10 +139,8 @@ pub impl<T:Copy Float> Mat2<T>: Matrix<T, Vec2<T>> {
*/
#[inline(always)]
static pure fn identity() -> Mat2<T> {
let _0 = Number::from(0);
let _1 = Number::from(1);
Mat2::new(_1, _0,
_0, _1)
Mat2::new(one(), zero(),
zero(), one())
}
/**
@ -159,9 +156,8 @@ pub impl<T:Copy Float> Mat2<T>: Matrix<T, Vec2<T>> {
*/
#[inline(always)]
static pure fn zero() -> Mat2<T> {
let _0 = Number::from(0);
Mat2::new(_0, _0,
_0, _0)
Mat2::new(zero(), zero(),
zero(), zero())
}
#[inline(always)]
@ -209,7 +205,7 @@ pub impl<T:Copy Float> Mat2<T>: Matrix<T, Vec2<T>> {
#[inline(always)]
pure fn inverse(&self) -> Option<Mat2<T>> {
let d = self.determinant();
if d.fuzzy_eq(&Number::from(0)) {
if d.fuzzy_eq(&zero()) {
None
} else {
Some(Mat2::new( self[1][1]/d, -self[0][1]/d,
@ -231,9 +227,8 @@ pub impl<T:Copy Float> Mat2<T>: Matrix<T, Vec2<T>> {
#[inline(always)]
pure fn is_diagonal(&self) -> bool {
let _0 = Number::from(0);
self[0][1].fuzzy_eq(&_0) &&
self[1][0].fuzzy_eq(&_0)
self[0][1].fuzzy_eq(&zero()) &&
self[1][0].fuzzy_eq(&zero())
}
#[inline(always)]
@ -250,7 +245,7 @@ pub impl<T:Copy Float> Mat2<T>: Matrix<T, Vec2<T>> {
#[inline(always)]
pure fn is_invertible(&self) -> bool {
!self.determinant().fuzzy_eq(&Number::from(0))
!self.determinant().fuzzy_eq(&zero())
}
#[inline(always)]
@ -336,21 +331,17 @@ pub impl<T:Copy Float> Mat2<T>: MutableMatrix<T, Vec2<T>> {
pub impl<T:Copy Float> Mat2<T>: Matrix2<T, Vec2<T>> {
#[inline(always)]
pure fn to_mat3(&self) -> Mat3<T> {
let _0 = Number::from(0);
let _1 = Number::from(1);
Mat3::new(self[0][0], self[0][1], _0,
self[1][0], self[1][1], _0,
_0, _0, _1)
Mat3::new(self[0][0], self[0][1], zero(),
self[1][0], self[1][1], zero(),
zero(), zero(), one())
}
#[inline(always)]
pure fn to_mat4(&self) -> Mat4<T> {
let _0 = Number::from(0);
let _1 = Number::from(1);
Mat4::new(self[0][0], self[0][1], _0, _0,
self[1][0], self[1][1], _0, _0,
_0, _0, _1, _0,
_0, _0, _0, _1)
Mat4::new(self[0][0], self[0][1], zero(), zero(),
self[1][0], self[1][1], zero(), zero(),
zero(), zero(), one(), zero(),
zero(), zero(), zero(), one())
}
}

View file

@ -8,6 +8,7 @@ use numeric::funs::*;
use numeric::types::angle::Angle;
use numeric::types::float::Float;
use numeric::types::number::Number;
use numeric::types::number::Number::{one, zero};
use quat::Quat;
use rot::Rotation;
@ -106,10 +107,9 @@ pub impl<T:Copy Float> Mat3<T> {
*/
#[inline(always)]
static pure fn from_value(value: T) -> Mat3<T> {
let _0 = Number::from(0);
Mat3::new(value, _0, _0,
_0, value, _0,
_0, _0, value)
Mat3::new(value, zero(), zero(),
zero(), value, zero(),
zero(), zero(), value)
}
/// Wrapper method for `Matrix::identity`
@ -129,12 +129,10 @@ pub impl<T:Copy Float> Mat3<T> {
// http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations
let cos_theta = cos(&theta.to_radians());
let sin_theta = sin(&theta.to_radians());
let _0 = Number::from(0);
let _1 = Number::from(1);
Mat3::new(_1, _0, _0,
_0, cos_theta, sin_theta,
_0, -sin_theta, cos_theta)
Mat3::new( one(), zero(), zero(),
zero(), cos_theta, sin_theta,
zero(), -sin_theta, cos_theta)
}
/**
@ -146,12 +144,10 @@ pub impl<T:Copy Float> Mat3<T> {
// http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations
let cos_theta = cos(&theta.to_radians());
let sin_theta = sin(&theta.to_radians());
let _0 = Number::from(0);
let _1 = Number::from(1);
Mat3::new(cos_theta, _0, -sin_theta,
_0, _1, _0,
sin_theta, _0, cos_theta)
Mat3::new(cos_theta, zero(), -sin_theta,
zero(), one(), zero(),
sin_theta, zero(), cos_theta)
}
/**
@ -163,12 +159,10 @@ pub impl<T:Copy Float> Mat3<T> {
// http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations
let cos_theta = cos(&theta.to_radians());
let sin_theta = sin(&theta.to_radians());
let _0 = Number::from(0);
let _1 = Number::from(1);
Mat3::new( cos_theta, sin_theta, _0,
-sin_theta, cos_theta, _0,
_0, _0, _1)
Mat3::new( cos_theta, sin_theta, zero(),
-sin_theta, cos_theta, zero(),
zero(), zero(), one())
}
/**
@ -202,11 +196,9 @@ pub impl<T:Copy Float> Mat3<T> {
// TODO: Move to Rotation implementation. See: https://github.com/mozilla/rust/issues/4306
#[inline(always)]
static pure fn from_angle_axis<A:Angle<T>>(theta: A, axis: &Vec3<T>) -> Mat3<T> {
let c: T = cos(&theta.to_radians());
let s: T = sin(&theta.to_radians());
let _0: T = Number::from(0);
let _1: T = Number::from(1);
let _1_c: T = _1 - c;
let c = cos(&theta.to_radians());
let s = sin(&theta.to_radians());
let _1_c = one::<T>() - c;
let x = axis.x;
let y = axis.y;
@ -261,7 +253,7 @@ pub impl<T:Copy Float> Mat3<T> {
let _1: T = Number::from(1.0);
let half: T = Number::from(0.5);
if trace >= Number::from(0) {
if trace >= zero() {
s = (_1 + trace).sqrt();
w = half * s;
s = half / s;
@ -321,11 +313,9 @@ pub impl<T:Copy Float> Mat3<T>: Matrix<T, Vec3<T>> {
*/
#[inline(always)]
static pure fn identity() -> Mat3<T> {
let _0 = Number::from(0);
let _1 = Number::from(1);
Mat3::new(_1, _0, _0,
_0, _1, _0,
_0, _0, _1)
Mat3::new( one(), zero(), zero(),
zero(), one(), zero(),
zero(), zero(), one())
}
/**
@ -343,10 +333,9 @@ pub impl<T:Copy Float> Mat3<T>: Matrix<T, Vec3<T>> {
*/
#[inline(always)]
static pure fn zero() -> Mat3<T> {
let _0 = Number::from(0);
Mat3::new(_0, _0, _0,
_0, _0, _0,
_0, _0, _0)
Mat3::new(zero(), zero(), zero(),
zero(), zero(), zero(),
zero(), zero(), zero())
}
#[inline(always)]
@ -407,7 +396,7 @@ pub impl<T:Copy Float> Mat3<T>: Matrix<T, Vec3<T>> {
// #[inline(always)]
pure fn inverse(&self) -> Option<Mat3<T>> {
let d = self.determinant();
if d.fuzzy_eq(&Number::from(0)) {
if d.fuzzy_eq(&zero()) {
None
} else {
Some(Mat3::from_cols(self[1].cross(&self[2]).div_t(d),
@ -431,15 +420,14 @@ pub impl<T:Copy Float> Mat3<T>: Matrix<T, Vec3<T>> {
#[inline(always)]
pure fn is_diagonal(&self) -> bool {
let _0 = Number::from(0);
self[0][1].fuzzy_eq(&_0) &&
self[0][2].fuzzy_eq(&_0) &&
self[0][1].fuzzy_eq(&zero()) &&
self[0][2].fuzzy_eq(&zero()) &&
self[1][0].fuzzy_eq(&_0) &&
self[1][2].fuzzy_eq(&_0) &&
self[1][0].fuzzy_eq(&zero()) &&
self[1][2].fuzzy_eq(&zero()) &&
self[2][0].fuzzy_eq(&_0) &&
self[2][1].fuzzy_eq(&_0)
self[2][0].fuzzy_eq(&zero()) &&
self[2][1].fuzzy_eq(&zero())
}
#[inline(always)]
@ -462,7 +450,7 @@ pub impl<T:Copy Float> Mat3<T>: Matrix<T, Vec3<T>> {
#[inline(always)]
pure fn is_invertible(&self) -> bool {
!self.determinant().fuzzy_eq(&Number::zero())
!self.determinant().fuzzy_eq(&zero())
}
#[inline(always)]
@ -559,12 +547,10 @@ pub impl<T:Copy Float> Mat3<T>: MutableMatrix<T, Vec3<T>> {
pub impl<T:Copy Float> Mat3<T>: Matrix3<T, Vec3<T>> {
#[inline(always)]
pure fn to_mat4(&self) -> Mat4<T> {
let _0 = Number::from(0);
let _1 = Number::from(1);
Mat4::new(self[0][0], self[0][1], self[0][2], _0,
self[1][0], self[1][1], self[1][2], _0,
self[2][0], self[2][1], self[2][2], _0,
_0, _0, _0, _1)
Mat4::new(self[0][0], self[0][1], self[0][2], zero(),
self[1][0], self[1][1], self[1][2], zero(),
self[2][0], self[2][1], self[2][2], zero(),
zero(), zero(), zero(), one())
}
}

View file

@ -7,7 +7,7 @@ use std::cmp::FuzzyEq;
use numeric::funs::*;
use numeric::types::angle::Angle;
use numeric::types::float::Float;
use numeric::types::number::Number;
use numeric::types::number::Number::{one, zero};
use vec::Vec4;
@ -116,11 +116,10 @@ pub impl<T:Copy Float> Mat4<T> {
*/
#[inline(always)]
static pure fn from_value(value: T) -> Mat4<T> {
let _0 = Number::from(0);
Mat4::new(value, _0, _0, _0,
_0, value, _0, _0,
_0, _0, value, _0,
_0, _0, _0, value)
Mat4::new(value, zero(), zero(), zero(),
zero(), value, zero(), zero(),
zero(), zero(), value, zero(),
zero(), zero(), zero(), value)
}
/// Wrapper method for `Matrix::identity`
@ -161,12 +160,10 @@ pub impl<T:Copy Float> Mat4<T>: Matrix<T, Vec4<T>> {
*/
#[inline(always)]
static pure fn identity() -> Mat4<T> {
let _0 = Number::from(0);
let _1 = Number::from(1);
Mat4::new(_1, _0, _0, _0,
_0, _1, _0, _0,
_0, _0, _1, _0,
_0, _0, _0, _1)
Mat4::new( one(), zero(), zero(), zero(),
zero(), one(), zero(), zero(),
zero(), zero(), one(), zero(),
zero(), zero(), zero(), one())
}
/**
@ -186,11 +183,10 @@ pub impl<T:Copy Float> Mat4<T>: Matrix<T, Vec4<T>> {
*/
#[inline(always)]
static pure fn zero() -> Mat4<T> {
let _0 = Number::from(0);
Mat4::new(_0, _0, _0, _0,
_0, _0, _0, _0,
_0, _0, _0, _0,
_0, _0, _0, _0)
Mat4::new(zero(), zero(), zero(), zero(),
zero(), zero(), zero(), zero(),
zero(), zero(), zero(), zero(),
zero(), zero(), zero(), zero())
}
#[inline(always)]
@ -274,7 +270,7 @@ pub impl<T:Copy Float> Mat4<T>: Matrix<T, Vec4<T>> {
pure fn inverse(&self) -> Option<Mat4<T>> {
let d = self.determinant();
if d.fuzzy_eq(&Number::from(0)) {
if d.fuzzy_eq(&zero()) {
None
} else {
@ -335,22 +331,21 @@ pub impl<T:Copy Float> Mat4<T>: Matrix<T, Vec4<T>> {
#[inline(always)]
pure fn is_diagonal(&self) -> bool {
let _0 = Number::from(0);
self[0][1].fuzzy_eq(&_0) &&
self[0][2].fuzzy_eq(&_0) &&
self[0][3].fuzzy_eq(&_0) &&
self[0][1].fuzzy_eq(&zero()) &&
self[0][2].fuzzy_eq(&zero()) &&
self[0][3].fuzzy_eq(&zero()) &&
self[1][0].fuzzy_eq(&_0) &&
self[1][2].fuzzy_eq(&_0) &&
self[1][3].fuzzy_eq(&_0) &&
self[1][0].fuzzy_eq(&zero()) &&
self[1][2].fuzzy_eq(&zero()) &&
self[1][3].fuzzy_eq(&zero()) &&
self[2][0].fuzzy_eq(&_0) &&
self[2][1].fuzzy_eq(&_0) &&
self[2][3].fuzzy_eq(&_0) &&
self[2][0].fuzzy_eq(&zero()) &&
self[2][1].fuzzy_eq(&zero()) &&
self[2][3].fuzzy_eq(&zero()) &&
self[3][0].fuzzy_eq(&_0) &&
self[3][1].fuzzy_eq(&_0) &&
self[3][2].fuzzy_eq(&_0)
self[3][0].fuzzy_eq(&zero()) &&
self[3][1].fuzzy_eq(&zero()) &&
self[3][2].fuzzy_eq(&zero())
}
#[inline(always)]
@ -380,7 +375,7 @@ pub impl<T:Copy Float> Mat4<T>: Matrix<T, Vec4<T>> {
#[inline(always)]
pure fn is_invertible(&self) -> bool {
!self.determinant().fuzzy_eq(&Number::zero())
!self.determinant().fuzzy_eq(&zero())
}
#[inline(always)]

View file

@ -18,6 +18,7 @@ use numeric::funs::*;
use numeric::types::angle::Angle;
use numeric::types::float::Float;
use numeric::types::number::Number;
use numeric::types::number::Number::{one, zero};
use mat::{Mat3, Mat4};
use vec::Vec3;
@ -74,10 +75,7 @@ pub impl<T:Copy Float> Quat<T> {
*/
#[inline(always)]
static pure fn identity() -> Quat<T> {
Quat::new(Number::one(),
Number::zero(),
Number::zero(),
Number::zero())
Quat::new(one(), zero(), zero(), zero())
}
/**
@ -87,10 +85,7 @@ pub impl<T:Copy Float> Quat<T> {
*/
#[inline(always)]
static pure fn zero() -> Quat<T> {
Quat::new(Number::zero(),
Number::zero(),
Number::zero(),
Number::zero())
Quat::new(zero(), zero(), zero(), zero())
}
/**
@ -234,9 +229,7 @@ pub impl<T:Copy Float> Quat<T> {
*/
#[inline(always)]
pure fn normalize(&self) -> Quat<T> {
let mut n: T = Number::from(1);
n /= self.magnitude();
return self.mul_t(n);
self.mul_t(one::<T>()/self.magnitude())
}
/**
@ -248,8 +241,7 @@ pub impl<T:Copy Float> Quat<T> {
*/
#[inline(always)]
pure fn nlerp(&self, other: &Quat<T>, amount: T) -> Quat<T> {
let _1: T = Number::from(1);
self.mul_t(_1 - amount).add_q(&other.mul_t(amount)).normalize()
self.mul_t(one::<T>() - amount).add_q(&other.mul_t(amount)).normalize()
}
/**
@ -282,8 +274,7 @@ pub impl<T:Copy Float> Quat<T> {
if dot > dot_threshold {
return self.nlerp(other, amount); // if quaternions are close together use `nlerp`
} else {
let robust_dot = dot.clamp(&-Number::from(1),
&Number::from(1)); // stay within the domain of acos()
let robust_dot = dot.clamp(&-one(), &one()); // stay within the domain of acos()
let theta_0 = acos(&robust_dot); // the angle between the quaternions
let theta = theta_0 * amount; // the fraction of theta specified by `amount`
@ -312,28 +303,25 @@ pub impl<T:Copy Float> Quat<T> {
// TODO: Move to Rotation implementation. See: https://github.com/mozilla/rust/issues/4306
#[inline(always)]
static pure fn from_angle_x<A:Angle<T>>(theta: A) -> Quat<T> {
let _0 = Number::from(0);
let _2 = Number::from(2);
let rad = theta.to_radians();
Quat::new((rad / _2).cos(), rad.sin(), _0, _0)
Quat::new((rad / _2).cos(), rad.sin(), zero(), zero())
}
// TODO: Move to Rotation implementation. See: https://github.com/mozilla/rust/issues/4306
#[inline(always)]
static pure fn from_angle_y<A:Angle<T>>(theta: A) -> Quat<T> {
let _0 = Number::from(0);
let _2 = Number::from(2);
let rad = theta.to_radians();
Quat::new((rad / _2).cos(), _0, rad.sin(), _0)
Quat::new((rad / _2).cos(), zero(), rad.sin(), zero())
}
// TODO: Move to Rotation implementation. See: https://github.com/mozilla/rust/issues/4306
#[inline(always)]
static pure fn from_angle_z<A:Angle<T>>(theta: A) -> Quat<T> {
let _0 = Number::from(0);
let _2 = Number::from(2);
let rad = theta.to_radians();
Quat::new((rad / _2).cos(), _0, _0, rad.sin())
Quat::new((rad / _2).cos(), zero(), zero(), rad.sin())
}
// TODO: Move to Rotation implementation. See: https://github.com/mozilla/rust/issues/4306
@ -399,7 +387,7 @@ pub impl<T:Copy Float> Quat<T> {
let sz2 = z2 * self.s;
let sx2 = x2 * self.s;
let _1: T = Number::from(1);
let _1: T = one();
Mat3::new(_1 - yy2 - zz2, xy2 + sz2, xz2 - sy2,
xy2 - sz2, _1 - xx2 - zz2, yz2 + sx2,

View file

@ -8,6 +8,7 @@ use numeric::funs::*;
use numeric::types::angle::Radians;
use numeric::types::float::Float;
use numeric::types::number::Number;
use numeric::types::number::Number::{one, zero};
/**
* A 2-dimensional vector
@ -75,20 +76,18 @@ pub impl<T:Copy> Vec2<T>: MutableVector<T> {
pub impl<T:Copy Number> Vec2<T>: NumericVector<T> {
#[inline(always)]
static pure fn identity() -> Vec2<T> {
Vec2::new(Number::one(),
Number::one())
Vec2::new(one(), one())
}
#[inline(always)]
static pure fn zero() -> Vec2<T> {
Vec2::new(Number::zero(),
Number::zero())
Vec2::new(zero(), zero())
}
#[inline(always)]
pure fn is_zero(&self) -> bool {
self[0] == Number::zero() &&
self[1] == Number::zero()
self[0] == zero() &&
self[1] == zero()
}
#[inline(always)]
@ -220,15 +219,12 @@ pub impl<T:Copy Float> Vec2<T>: EuclideanVector<T> {
#[inline(always)]
pure fn normalize(&self) -> Vec2<T> {
let mut n: T = Number::from(1);
n /= self.length();
return self.mul_t(n);
self.mul_t(one::<T>()/self.length())
}
#[inline(always)]
pure fn normalize_to(&self, length: T) -> Vec2<T> {
let mut n: T = length / self.length();
return self.mul_t(n);
self.mul_t(length / self.length())
}
#[inline(always)]
@ -240,14 +236,13 @@ pub impl<T:Copy Float> Vec2<T>: EuclideanVector<T> {
pub impl<T:Copy Float> Vec2<T>: MutableEuclideanVector<&self/T> {
#[inline(always)]
fn normalize_self(&mut self) {
let mut n: T = Number::from(1);
n /= self.length();
let n = one::<T>() / self.length();
self.mul_self_t(&n);
}
#[inline(always)]
fn normalize_self_to(&mut self, length: &T) {
let mut n: T = length / self.length();
let n = length / self.length();
self.mul_self_t(&n);
}

View file

@ -8,6 +8,7 @@ use numeric::funs::*;
use numeric::types::angle::Radians;
use numeric::types::float::Float;
use numeric::types::number::Number;
use numeric::types::number::Number::{one, zero};
/**
* A 3-dimensional vector
@ -77,23 +78,19 @@ pub impl<T:Copy> Vec3<T>: MutableVector<T> {
pub impl<T:Copy Number> Vec3<T>: NumericVector<T> {
#[inline(always)]
static pure fn identity() -> Vec3<T> {
Vec3::new(Number::one(),
Number::one(),
Number::one())
Vec3::new(one(), one(), one())
}
#[inline(always)]
static pure fn zero() -> Vec3<T> {
Vec3::new(Number::zero(),
Number::zero(),
Number::zero())
Vec3::new(zero(), zero(), zero())
}
#[inline(always)]
pure fn is_zero(&self) -> bool {
self[0] == Number::zero() &&
self[1] == Number::zero() &&
self[2] == Number::zero()
self[0] == zero() &&
self[1] == zero() &&
self[2] == zero()
}
#[inline(always)]
@ -248,15 +245,12 @@ pub impl<T:Copy Float> Vec3<T>: EuclideanVector<T> {
#[inline(always)]
pure fn normalize(&self) -> Vec3<T> {
let mut n: T = Number::from(1);
n /= self.length();
return self.mul_t(n);
self.mul_t(one::<T>()/self.length())
}
#[inline(always)]
pure fn normalize_to(&self, length: T) -> Vec3<T> {
let mut n: T = length / self.length();
return self.mul_t(n);
self.mul_t(length / self.length())
}
#[inline(always)]
@ -268,14 +262,13 @@ pub impl<T:Copy Float> Vec3<T>: EuclideanVector<T> {
pub impl<T:Copy Float> Vec3<T>: MutableEuclideanVector<&self/T> {
#[inline(always)]
fn normalize_self(&mut self) {
let mut n: T = Number::from(1);
n /= self.length();
let n = one::<T>() / self.length();
self.mul_self_t(&n);
}
#[inline(always)]
fn normalize_self_to(&mut self, length: &T) {
let mut n: T = length / self.length();
let n = length / self.length();
self.mul_self_t(&n);
}

View file

@ -8,6 +8,7 @@ use numeric::funs::*;
use numeric::types::angle::Radians;
use numeric::types::float::Float;
use numeric::types::number::Number;
use numeric::types::number::Number::{one, zero};
/**
* A 4-dimensional vector
@ -79,18 +80,12 @@ pub impl<T:Copy> Vec4<T>: MutableVector<T> {
pub impl<T:Copy Number> Vec4<T>: NumericVector<T> {
#[inline(always)]
static pure fn identity() -> Vec4<T> {
Vec4::new(Number::one(),
Number::one(),
Number::one(),
Number::one())
Vec4::new(one(), one(), one(), one())
}
#[inline(always)]
static pure fn zero() -> Vec4<T> {
Vec4::new(Number::zero(),
Number::zero(),
Number::zero(),
Number::zero())
Vec4::new(zero(), zero(), zero(), zero())
}
#[inline(always)]
@ -251,15 +246,12 @@ pub impl<T:Copy Float> Vec4<T>: EuclideanVector<T> {
#[inline(always)]
pure fn normalize(&self) -> Vec4<T> {
let mut n: T = Number::from(1);
n /= self.length();
return self.mul_t(n);
self.mul_t(one::<T>()/self.length())
}
#[inline(always)]
pure fn normalize_to(&self, length: T) -> Vec4<T> {
let mut n: T = length / self.length();
return self.mul_t(n);
self.mul_t(length / self.length())
}
#[inline(always)]
@ -271,14 +263,13 @@ pub impl<T:Copy Float> Vec4<T>: EuclideanVector<T> {
pub impl<T:Copy Float> Vec4<T>: MutableEuclideanVector<&self/T> {
#[inline(always)]
fn normalize_self(&mut self) {
let mut n: T = Number::from(1);
n /= self.length();
let n = one::<T>() / self.length();
self.mul_self_t(&n);
}
#[inline(always)]
fn normalize_self_to(&mut self, length: &T) {
let mut n: T = length / self.length();
let n = length / self.length();
self.mul_self_t(&n);
}