diff --git a/src/mat.rs b/src/mat.rs index 73821ca..8e4dbd2 100644 --- a/src/mat.rs +++ b/src/mat.rs @@ -24,89 +24,89 @@ pub trait Matrix: Index + Eq + Neg { * * The column vector at `i` */ - pure fn col(&self, i: uint) -> V; + fn col(&self, i: uint) -> V; /** * # Return value * * The row vector at `i` */ - pure fn row(&self, i: uint) -> V; + fn row(&self, i: uint) -> V; /** * Construct a diagonal matrix with the major diagonal set to `value` */ - static pure fn from_value(value: T) -> Self; + static fn from_value(value: T) -> Self; /** * # Return value * * The identity matrix */ - static pure fn identity() -> Self; + static fn identity() -> Self; /** * # Return value * * A matrix with all elements set to zero */ - static pure fn zero() -> Self; + static fn zero() -> Self; /** * # Return value * * The scalar multiplication of this matrix and `value` */ - pure fn mul_t(&self, value: T) -> Self; + fn mul_t(&self, value: T) -> Self; /** * # Return value * * The matrix vector product of the matrix and `vec` */ - pure fn mul_v(&self, vec: &V) -> V; + fn mul_v(&self, vec: &V) -> V; /** * # Return value * * The matrix addition of the matrix and `other` */ - pure fn add_m(&self, other: &Self) -> Self; + fn add_m(&self, other: &Self) -> Self; /** * # Return value * * The difference between the matrix and `other` */ - pure fn sub_m(&self, other: &Self) -> Self; + fn sub_m(&self, other: &Self) -> Self; /** * # Return value * * The matrix product of the matrix and `other` */ - pure fn mul_m(&self, other: &Self) -> Self; + fn mul_m(&self, other: &Self) -> Self; /** * # Return value * * The matrix dot product of the matrix and `other` */ - pure fn dot(&self, other: &Self) -> T; + fn dot(&self, other: &Self) -> T; /** * # Return value * * The determinant of the matrix */ - pure fn determinant(&self) -> T; + fn determinant(&self) -> T; /** * # Return value * * The sum of the main diagonal of the matrix */ - pure fn trace(&self) -> T; + fn trace(&self) -> T; /** * Returns the inverse of the matrix @@ -116,14 +116,14 @@ pub trait Matrix: Index + Eq + Neg { * * `Some(m)` - if the inversion was successful, where `m` is the inverted matrix * * `None` - if the inversion was unsuccessful (because the matrix was not invertable) */ - pure fn inverse(&self) -> Option; + fn inverse(&self) -> Option; /** * # Return value * * The transposed matrix */ - pure fn transpose(&self) -> Self; + fn transpose(&self) -> Self; /** * Check to see if the matrix is an identity matrix @@ -132,7 +132,7 @@ pub trait Matrix: Index + Eq + Neg { * * `true` if the matrix is approximately equal to the identity matrix */ - pure fn is_identity(&self) -> bool; + fn is_identity(&self) -> bool; /** * Check to see if the matrix is diagonal @@ -142,7 +142,7 @@ pub trait Matrix: Index + Eq + Neg { * `true` all the elements outside the main diagonal are approximately * equal to zero. */ - pure fn is_diagonal(&self) -> bool; + fn is_diagonal(&self) -> bool; /** * Check to see if the matrix is rotated @@ -151,7 +151,7 @@ pub trait Matrix: Index + Eq + Neg { * * `true` if the matrix is not approximately equal to the identity matrix. */ - pure fn is_rotated(&self) -> bool; + fn is_rotated(&self) -> bool; /** * Check to see if the matrix is symmetric @@ -160,7 +160,7 @@ pub trait Matrix: Index + Eq + Neg { * * `true` if the matrix is approximately equal to its transpose). */ - pure fn is_symmetric(&self) -> bool; + fn is_symmetric(&self) -> bool; /** * Check to see if the matrix is invertable @@ -169,71 +169,71 @@ pub trait Matrix: Index + Eq + Neg { * * `true` if the matrix is invertable */ - pure fn is_invertible(&self) -> bool; + fn is_invertible(&self) -> bool; /** * # Return value * * A pointer to the first element of the matrix */ - pure fn to_ptr(&self) -> *T; + fn to_ptr(&self) -> *T; } /** * A 2 x 2 matrix */ pub trait Matrix2: Matrix { - static pure fn new(c0r0: T, c0r1: T, + static fn new(c0r0: T, c0r1: T, c1r0: T, c1r1: T) -> Self; - static pure fn from_cols(c0: V, c1: V) -> Self; + static fn from_cols(c0: V, c1: V) -> Self; - static pure fn from_angle(radians: T) -> Self; + static fn from_angle(radians: T) -> Self; - pure fn to_mat3(&self) -> Mat3; + fn to_mat3(&self) -> Mat3; - pure fn to_mat4(&self) -> Mat4; + fn to_mat4(&self) -> Mat4; } /** * A 3 x 3 matrix */ pub trait Matrix3: Matrix { - static pure fn new(c0r0:T, c0r1:T, c0r2:T, + static fn new(c0r0:T, c0r1:T, c0r2:T, c1r0:T, c1r1:T, c1r2:T, c2r0:T, c2r1:T, c2r2:T) -> Self; - static pure fn from_cols(c0: V, c1: V, c2: V) -> Self; + static fn from_cols(c0: V, c1: V, c2: V) -> Self; - static pure fn from_angle_x(radians: T) -> Self; + static fn from_angle_x(radians: T) -> Self; - static pure fn from_angle_y(radians: T) -> Self; + static fn from_angle_y(radians: T) -> Self; - static pure fn from_angle_z(radians: T) -> Self; + static fn from_angle_z(radians: T) -> Self; - static pure fn from_angle_xyz(radians_x: T, radians_y: T, radians_z: T) -> Self; + static fn from_angle_xyz(radians_x: T, radians_y: T, radians_z: T) -> Self; - static pure fn from_angle_axis(radians: T, axis: &Vec3) -> Self; + static fn from_angle_axis(radians: T, axis: &Vec3) -> Self; - static pure fn from_axes(x: V, y: V, z: V) -> Self; + static fn from_axes(x: V, y: V, z: V) -> Self; - static pure fn look_at(dir: &Vec3, up: &Vec3) -> Self; + static fn look_at(dir: &Vec3, up: &Vec3) -> Self; - pure fn to_mat4(&self) -> Mat4; + fn to_mat4(&self) -> Mat4; - pure fn to_quat(&self) -> Quat; + fn to_quat(&self) -> Quat; } /** * A 4 x 4 matrix */ pub trait Matrix4: Matrix { - static pure fn new(c0r0: T, c0r1: T, c0r2: T, c0r3: T, + static fn new(c0r0: T, c0r1: T, c0r2: T, c0r3: T, c1r0: T, c1r1: T, c1r2: T, c1r3: T, c2r0: T, c2r1: T, c2r2: T, c2r3: T, c3r0: T, c3r1: T, c3r2: T, c3r3: T) -> Self; - static pure fn from_cols(c0: V, c1: V, c2: V, c3: V) -> Self; + static fn from_cols(c0: V, c1: V, c2: V, c3: V) -> Self; } /** diff --git a/src/mat2.rs b/src/mat2.rs index 4605339..a313fdc 100644 --- a/src/mat2.rs +++ b/src/mat2.rs @@ -48,10 +48,10 @@ pub struct Mat2 { x: Vec2, y: Vec2 } impl + Add + Sub + Mul + Div + Neg> Matrix> for Mat2 { #[inline(always)] - pure fn col(&self, i: uint) -> Vec2 { self[i] } + fn col(&self, i: uint) -> Vec2 { self[i] } #[inline(always)] - pure fn row(&self, i: uint) -> Vec2 { + fn row(&self, i: uint) -> Vec2 { Vector2::new(self[0][i], self[1][i]) } @@ -73,7 +73,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn from_value(value: T) -> Mat2 { + static fn from_value(value: T) -> Mat2 { Matrix2::new(value, zero(), zero(), value) } @@ -90,7 +90,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn identity() -> Mat2 { + static fn identity() -> Mat2 { Matrix2::new( one::(), zero::(), zero::(), one::()) } @@ -107,55 +107,55 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn zero() -> Mat2 { + static fn zero() -> Mat2 { Matrix2::new(zero::(), zero::(), zero::(), zero::()) } #[inline(always)] - pure fn mul_t(&self, value: T) -> Mat2 { + fn mul_t(&self, value: T) -> Mat2 { Matrix2::from_cols(self[0].mul_t(value), self[1].mul_t(value)) } #[inline(always)] - pure fn mul_v(&self, vec: &Vec2) -> Vec2 { + fn mul_v(&self, vec: &Vec2) -> Vec2 { Vector2::new(self.row(0).dot(vec), self.row(1).dot(vec)) } #[inline(always)] - pure fn add_m(&self, other: &Mat2) -> Mat2 { + fn add_m(&self, other: &Mat2) -> Mat2 { Matrix2::from_cols(self[0].add_v(&other[0]), self[1].add_v(&other[1])) } #[inline(always)] - pure fn sub_m(&self, other: &Mat2) -> Mat2 { + fn sub_m(&self, other: &Mat2) -> Mat2 { Matrix2::from_cols(self[0].sub_v(&other[0]), self[1].sub_v(&other[1])) } #[inline(always)] - pure fn mul_m(&self, other: &Mat2) -> Mat2 { + fn mul_m(&self, other: &Mat2) -> Mat2 { Matrix2::new(self.row(0).dot(&other.col(0)), self.row(1).dot(&other.col(0)), self.row(0).dot(&other.col(1)), self.row(1).dot(&other.col(1))) } - pure fn dot(&self, other: &Mat2) -> T { + fn dot(&self, other: &Mat2) -> T { other.transpose().mul_m(self).trace() } - pure fn determinant(&self) -> T { + fn determinant(&self) -> T { self[0][0] * self[1][1] - self[1][0] * self[0][1] } - pure fn trace(&self) -> T { + fn trace(&self) -> T { self[0][0] + self[1][1] } #[inline(always)] - pure fn inverse(&self) -> Option> { + fn inverse(&self) -> Option> { let d = self.determinant(); if d.fuzzy_eq(&zero()) { None @@ -166,40 +166,40 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn transpose(&self) -> Mat2 { + fn transpose(&self) -> Mat2 { Matrix2::new(self[0][0], self[1][0], self[0][1], self[1][1]) } #[inline(always)] - pure fn is_identity(&self) -> bool { + fn is_identity(&self) -> bool { self.fuzzy_eq(&Matrix::identity()) } #[inline(always)] - pure fn is_diagonal(&self) -> bool { + fn is_diagonal(&self) -> bool { self[0][1].fuzzy_eq(&zero()) && self[1][0].fuzzy_eq(&zero()) } #[inline(always)] - pure fn is_rotated(&self) -> bool { + fn is_rotated(&self) -> bool { !self.fuzzy_eq(&Matrix::identity()) } #[inline(always)] - pure fn is_symmetric(&self) -> bool { + fn is_symmetric(&self) -> bool { self[0][1].fuzzy_eq(&self[1][0]) && self[1][0].fuzzy_eq(&self[0][1]) } #[inline(always)] - pure fn is_invertible(&self) -> bool { + fn is_invertible(&self) -> bool { !self.determinant().fuzzy_eq(&zero()) } #[inline(always)] - pure fn to_ptr(&self) -> *T { + fn to_ptr(&self) -> *T { unsafe { transmute::<*Mat2, *T>( to_unsafe_ptr(self) @@ -296,7 +296,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn new(c0r0: T, c0r1: T, + static fn new(c0r0: T, c0r1: T, c1r0: T, c1r1: T) -> Mat2 { Matrix2::from_cols(Vector2::new::>(c0r0, c0r1), Vector2::new::>(c1r0, c1r1)) @@ -320,13 +320,13 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn from_cols(c0: Vec2, + static fn from_cols(c0: Vec2, c1: Vec2) -> Mat2 { Mat2 { x: c0, y: c1 } } #[inline(always)] - static pure fn from_angle(radians: T) -> Mat2 { + static fn from_angle(radians: T) -> Mat2 { let cos_theta = cos(radians); let sin_theta = sin(radians); @@ -348,7 +348,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - pure fn to_mat3(&self) -> Mat3 { + fn to_mat3(&self) -> Mat3 { Matrix3::new(self[0][0], self[0][1], zero(), self[1][0], self[1][1], zero(), zero(), zero(), one()) @@ -370,7 +370,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - pure fn to_mat4(&self) -> Mat4 { + fn to_mat4(&self) -> Mat4 { Matrix4::new(self[0][0], self[0][1], zero(), zero(), self[1][0], self[1][1], zero(), zero(), zero(), zero(), one(), zero(), @@ -380,7 +380,7 @@ impl + Add + Sub + Mul + Div + N impl Index> for Mat2 { #[inline(always)] - pure fn index(&self, i: uint) -> Vec2 { + fn index(&self, i: uint) -> Vec2 { unsafe { do buf_as_slice( transmute::<*Mat2, *Vec2>( to_unsafe_ptr(self)), 2) |slice| { slice[i] } @@ -390,19 +390,19 @@ impl Index> for Mat2 { impl + Add + Sub + Mul + Div + Neg> Neg> for Mat2 { #[inline(always)] - pure fn neg(&self) -> Mat2 { + fn neg(&self) -> Mat2 { Matrix2::from_cols(-self[0], -self[1]) } } impl> FuzzyEq for Mat2 { #[inline(always)] - pure fn fuzzy_eq(&self, other: &Mat2) -> bool { + fn fuzzy_eq(&self, other: &Mat2) -> bool { self.fuzzy_eq_eps(other, &Number::from(FUZZY_EPSILON)) } #[inline(always)] - pure fn fuzzy_eq_eps(&self, other: &Mat2, epsilon: &T) -> bool { + fn fuzzy_eq_eps(&self, other: &Mat2, epsilon: &T) -> bool { self[0].fuzzy_eq_eps(&other[0], epsilon) && self[1].fuzzy_eq_eps(&other[1], epsilon) } @@ -417,37 +417,37 @@ pub type dmat2 = Mat2; // a 2×2 double-precision floating-point matrix // Static method wrappers for GLSL-style types impl mat2 { - #[inline(always)] static pure fn new(c0r0: f32, c0r1: f32, c1r0: f32, c1r1: f32) + #[inline(always)] static fn new(c0r0: f32, c0r1: f32, c1r0: f32, c1r1: f32) -> mat2 { Matrix2::new(c0r0, c0r1, c1r0, c1r1) } - #[inline(always)] static pure fn from_cols(c0: vec2, c1: vec2) + #[inline(always)] static fn from_cols(c0: vec2, c1: vec2) -> mat2 { Matrix2::from_cols(c0, c1) } - #[inline(always)] static pure fn from_value(v: f32) -> mat2 { Matrix::from_value(v) } + #[inline(always)] static fn from_value(v: f32) -> mat2 { Matrix::from_value(v) } - #[inline(always)] static pure fn identity() -> mat2 { Matrix::identity() } - #[inline(always)] static pure fn zero() -> mat2 { Matrix::zero() } + #[inline(always)] static fn identity() -> mat2 { Matrix::identity() } + #[inline(always)] static fn zero() -> mat2 { Matrix::zero() } - #[inline(always)] static pure fn from_angle(radians: f32) -> mat2 { Matrix2::from_angle(radians) } + #[inline(always)] static fn from_angle(radians: f32) -> mat2 { Matrix2::from_angle(radians) } - #[inline(always)] static pure fn dim() -> uint { 2 } - #[inline(always)] static pure fn rows() -> uint { 2 } - #[inline(always)] static pure fn cols() -> uint { 2 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 2 } + #[inline(always)] static fn rows() -> uint { 2 } + #[inline(always)] static fn cols() -> uint { 2 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl dmat2 { - #[inline(always)] static pure fn new(c0r0: f64, c0r1: f64, c1r0: f64, c1r1: f64) + #[inline(always)] static fn new(c0r0: f64, c0r1: f64, c1r0: f64, c1r1: f64) -> dmat2 { Matrix2::new(c0r0, c0r1, c1r0, c1r1) } - #[inline(always)] static pure fn from_cols(c0: dvec2, c1: dvec2) + #[inline(always)] static fn from_cols(c0: dvec2, c1: dvec2) -> dmat2 { Matrix2::from_cols(c0, c1) } - #[inline(always)] static pure fn from_value(v: f64) -> dmat2 { Matrix::from_value(v) } + #[inline(always)] static fn from_value(v: f64) -> dmat2 { Matrix::from_value(v) } - #[inline(always)] static pure fn identity() -> dmat2 { Matrix::identity() } - #[inline(always)] static pure fn zero() -> dmat2 { Matrix::zero() } + #[inline(always)] static fn identity() -> dmat2 { Matrix::identity() } + #[inline(always)] static fn zero() -> dmat2 { Matrix::zero() } - #[inline(always)] static pure fn from_angle(radians: f64) -> dmat2 { Matrix2::from_angle(radians) } + #[inline(always)] static fn from_angle(radians: f64) -> dmat2 { Matrix2::from_angle(radians) } - #[inline(always)] static pure fn dim() -> uint { 2 } - #[inline(always)] static pure fn rows() -> uint { 2 } - #[inline(always)] static pure fn cols() -> uint { 2 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 2 } + #[inline(always)] static fn rows() -> uint { 2 } + #[inline(always)] static fn cols() -> uint { 2 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } diff --git a/src/mat3.rs b/src/mat3.rs index 54232da..b3ab371 100644 --- a/src/mat3.rs +++ b/src/mat3.rs @@ -50,10 +50,10 @@ pub struct Mat3 { x: Vec3, y: Vec3, z: Vec3 } impl + Add + Sub + Mul + Div + Neg> Matrix> for Mat3 { #[inline(always)] - pure fn col(&self, i: uint) -> Vec3 { self[i] } + fn col(&self, i: uint) -> Vec3 { self[i] } #[inline(always)] - pure fn row(&self, i: uint) -> Vec3 { + fn row(&self, i: uint) -> Vec3 { Vector3::new(self[0][i], self[1][i], self[2][i]) @@ -78,7 +78,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn from_value(value: T) -> Mat3 { + static fn from_value(value: T) -> Mat3 { Matrix3::new(value, zero(), zero(), zero(), value, zero(), zero(), zero(), value) @@ -98,7 +98,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn identity() -> Mat3 { + static fn identity() -> Mat3 { Matrix3::new( one::(), zero::(), zero::(), zero::(), one::(), zero::(), zero::(), zero::(), one::()) @@ -118,42 +118,42 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn zero() -> Mat3 { + static fn zero() -> Mat3 { Matrix3::new(zero::(), zero::(), zero::(), zero::(), zero::(), zero::(), zero::(), zero::(), zero::()) } #[inline(always)] - pure fn mul_t(&self, value: T) -> Mat3 { + fn mul_t(&self, value: T) -> Mat3 { Matrix3::from_cols(self[0].mul_t(value), self[1].mul_t(value), self[2].mul_t(value)) } #[inline(always)] - pure fn mul_v(&self, vec: &Vec3) -> Vec3 { + fn mul_v(&self, vec: &Vec3) -> Vec3 { Vector3::new(self.row(0).dot(vec), self.row(1).dot(vec), self.row(2).dot(vec)) } #[inline(always)] - pure fn add_m(&self, other: &Mat3) -> Mat3 { + fn add_m(&self, other: &Mat3) -> Mat3 { Matrix3::from_cols(self[0].add_v(&other[0]), self[1].add_v(&other[1]), self[2].add_v(&other[2])) } #[inline(always)] - pure fn sub_m(&self, other: &Mat3) -> Mat3 { + fn sub_m(&self, other: &Mat3) -> Mat3 { Matrix3::from_cols(self[0].sub_v(&other[0]), self[1].sub_v(&other[1]), self[2].sub_v(&other[2])) } #[inline(always)] - pure fn mul_m(&self, other: &Mat3) -> Mat3 { + fn mul_m(&self, other: &Mat3) -> Mat3 { Matrix3::new(self.row(0).dot(&other.col(0)), self.row(1).dot(&other.col(0)), self.row(2).dot(&other.col(0)), @@ -167,20 +167,20 @@ impl + Add + Sub + Mul + Div + N self.row(2).dot(&other.col(2))) } - pure fn dot(&self, other: &Mat3) -> T { + fn dot(&self, other: &Mat3) -> T { other.transpose().mul_m(self).trace() } - pure fn determinant(&self) -> T { + fn determinant(&self) -> T { self.col(0).dot(&self.col(1).cross(&self.col(2))) } - pure fn trace(&self) -> T { + fn trace(&self) -> T { self[0][0] + self[1][1] + self[2][2] } // #[inline(always)] - pure fn inverse(&self) -> Option> { + fn inverse(&self) -> Option> { let d = self.determinant(); if d.fuzzy_eq(&zero()) { None @@ -193,19 +193,19 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn transpose(&self) -> Mat3 { + fn transpose(&self) -> Mat3 { Matrix3::new(self[0][0], self[1][0], self[2][0], self[0][1], self[1][1], self[2][1], self[0][2], self[1][2], self[2][2]) } #[inline(always)] - pure fn is_identity(&self) -> bool { + fn is_identity(&self) -> bool { self.fuzzy_eq(&Matrix::identity()) } #[inline(always)] - pure fn is_diagonal(&self) -> bool { + fn is_diagonal(&self) -> bool { self[0][1].fuzzy_eq(&zero()) && self[0][2].fuzzy_eq(&zero()) && @@ -217,12 +217,12 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn is_rotated(&self) -> bool { + fn is_rotated(&self) -> bool { !self.fuzzy_eq(&Matrix::identity()) } #[inline(always)] - pure fn is_symmetric(&self) -> bool { + fn is_symmetric(&self) -> bool { self[0][1].fuzzy_eq(&self[1][0]) && self[0][2].fuzzy_eq(&self[2][0]) && @@ -234,12 +234,12 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn is_invertible(&self) -> bool { + fn is_invertible(&self) -> bool { !self.determinant().fuzzy_eq(&zero()) } #[inline(always)] - pure fn to_ptr(&self) -> *T { + fn to_ptr(&self) -> *T { unsafe { transmute::<*Mat3, *T>( to_unsafe_ptr(self) @@ -270,7 +270,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn new(c0r0:T, c0r1:T, c0r2:T, + static fn new(c0r0:T, c0r1:T, c0r2:T, c1r0:T, c1r1:T, c1r2:T, c2r0:T, c2r1:T, c2r2:T) -> Mat3 { Matrix3::from_cols(Vector3::new::>(c0r0, c0r1, c0r2), @@ -299,7 +299,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn from_cols(c0: Vec3, + static fn from_cols(c0: Vec3, c1: Vec3, c2: Vec3) -> Mat3 { Mat3 { x: c0, y: c1, z: c2 } @@ -309,7 +309,7 @@ impl + Add + Sub + Mul + Div + N * Construct a matrix from an angular rotation around the `x` axis */ #[inline(always)] - static pure fn from_angle_x(radians: T) -> Mat3 { + static fn from_angle_x(radians: T) -> Mat3 { // http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations let cos_theta = cos(radians); let sin_theta = sin(radians); @@ -323,7 +323,7 @@ impl + Add + Sub + Mul + Div + N * Construct a matrix from an angular rotation around the `y` axis */ #[inline(always)] - static pure fn from_angle_y(radians: T) -> Mat3 { + static fn from_angle_y(radians: T) -> Mat3 { // http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations let cos_theta = cos(radians); let sin_theta = sin(radians); @@ -337,7 +337,7 @@ impl + Add + Sub + Mul + Div + N * Construct a matrix from an angular rotation around the `z` axis */ #[inline(always)] - static pure fn from_angle_z(radians: T) -> Mat3 { + static fn from_angle_z(radians: T) -> Mat3 { // http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations let cos_theta = cos(radians); let sin_theta = sin(radians); @@ -357,7 +357,7 @@ impl + Add + Sub + Mul + Div + N * * `theta_z` - the angular rotation around the `z` axis (roll) */ #[inline(always)] - static pure fn from_angle_xyz(radians_x: T, radians_y: T, radians_z: T) -> Mat3 { + static fn from_angle_xyz(radians_x: T, radians_y: T, radians_z: T) -> Mat3 { // http://en.wikipedia.org/wiki/Rotation_matrix#General_rotations let cx = cos(radians_x); let sx = sin(radians_x); @@ -375,7 +375,7 @@ impl + Add + Sub + Mul + Div + N * Construct a matrix from an axis and an angular rotation */ #[inline(always)] - static pure fn from_angle_axis(radians: T, axis: &Vec3) -> Mat3 { + static fn from_angle_axis(radians: T, axis: &Vec3) -> Mat3 { let c = cos(radians); let s = sin(radians); let _1_c = one::() - c; @@ -390,12 +390,12 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - static pure fn from_axes(x: Vec3, y: Vec3, z: Vec3) -> Mat3 { + static fn from_axes(x: Vec3, y: Vec3, z: Vec3) -> Mat3 { Matrix3::from_cols(x, y, z) } #[inline(always)] - static pure fn look_at(dir: &Vec3, up: &Vec3) -> Mat3 { + static fn look_at(dir: &Vec3, up: &Vec3) -> Mat3 { let dir_ = dir.normalize(); let side = dir_.cross(&up.normalize()); let up_ = side.cross(&dir_).normalize(); @@ -419,7 +419,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - pure fn to_mat4(&self) -> Mat4 { + fn to_mat4(&self) -> Mat4 { Matrix4::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(), @@ -430,7 +430,7 @@ impl + Add + Sub + Mul + Div + N * Convert the matrix to a quaternion */ #[inline(always)] - pure fn to_quat(&self) -> Quat { + fn to_quat(&self) -> Quat { // Implemented using a mix of ideas from jMonkeyEngine and Ken Shoemake's // paper on Quaternions: http://www.cs.ucr.edu/~vbz/resources/Quatut.pdf @@ -558,7 +558,7 @@ impl + Add + Sub + Mul + Div + N impl Index> for Mat3 { #[inline(always)] - pure fn index(&self, i: uint) -> Vec3 { + fn index(&self, i: uint) -> Vec3 { unsafe { do buf_as_slice( transmute::<*Mat3, *Vec3>( to_unsafe_ptr(self)), 3) |slice| { slice[i] } @@ -568,19 +568,19 @@ impl Index> for Mat3 { impl + Add + Sub + Mul + Div + Neg> Neg> for Mat3 { #[inline(always)] - pure fn neg(&self) -> Mat3 { + fn neg(&self) -> Mat3 { Matrix3::from_cols(-self[0], -self[1], -self[2]) } } impl + Add + Sub + Mul + Div + Neg> FuzzyEq for Mat3 { #[inline(always)] - pure fn fuzzy_eq(&self, other: &Mat3) -> bool { + fn fuzzy_eq(&self, other: &Mat3) -> bool { self.fuzzy_eq_eps(other, &Number::from(FUZZY_EPSILON)) } #[inline(always)] - pure fn fuzzy_eq_eps(&self, other: &Mat3, epsilon: &T) -> bool { + fn fuzzy_eq_eps(&self, other: &Mat3, epsilon: &T) -> bool { self[0].fuzzy_eq_eps(&other[0], epsilon) && self[1].fuzzy_eq_eps(&other[1], epsilon) && self[2].fuzzy_eq_eps(&other[2], epsilon) @@ -596,42 +596,42 @@ pub type dmat3 = Mat3; // a 3×3 double-precision floating-point matrix // Static method wrappers for GLSL-style types impl mat3 { - #[inline(always)] static pure fn new(c0r0: f32, c0r1: f32, c0r2: f32, c1r0: f32, c1r1: f32, c1r2: f32, c2r0: f32, c2r1: f32, c2r2: f32) + #[inline(always)] static fn new(c0r0: f32, c0r1: f32, c0r2: f32, c1r0: f32, c1r1: f32, c1r2: f32, c2r0: f32, c2r1: f32, c2r2: f32) -> mat3 { Matrix3::new(c0r0, c0r1, c0r2, c1r0, c1r1, c1r2, c2r0, c2r1, c2r2) } - #[inline(always)] static pure fn from_cols(c0: vec3, c1: vec3, c2: vec3) + #[inline(always)] static fn from_cols(c0: vec3, c1: vec3, c2: vec3) -> mat3 { Matrix3::from_cols(c0, c1, c2) } - #[inline(always)] static pure fn from_value(v: f32) -> mat3 { Matrix::from_value(v) } + #[inline(always)] static fn from_value(v: f32) -> mat3 { Matrix::from_value(v) } - #[inline(always)] static pure fn identity() -> mat3 { Matrix::identity() } - #[inline(always)] static pure fn zero() -> mat3 { Matrix::zero() } + #[inline(always)] static fn identity() -> mat3 { Matrix::identity() } + #[inline(always)] static fn zero() -> mat3 { Matrix::zero() } - #[inline(always)] static pure fn from_angle_x(radians: f32) -> mat3 { Matrix3::from_angle_x(radians) } - #[inline(always)] static pure fn from_angle_y(radians: f32) -> mat3 { Matrix3::from_angle_y(radians) } - #[inline(always)] static pure fn from_angle_z(radians: f32) -> mat3 { Matrix3::from_angle_z(radians) } - #[inline(always)] static pure fn from_angle_xyz(radians_x: f32, radians_y: f32, radians_z: f32) -> mat3 { Matrix3::from_angle_xyz(radians_x, radians_y, radians_z) } - #[inline(always)] static pure fn from_angle_axis(radians: f32, axis: &vec3) -> mat3 { Matrix3::from_angle_axis(radians, axis) } - #[inline(always)] static pure fn from_axes(x: vec3, y: vec3, z: vec3) -> mat3 { Matrix3::from_axes(x, y, z) } - #[inline(always)] static pure fn look_at(dir: &vec3, up: &vec3) -> mat3 { Matrix3::look_at(dir, up) } + #[inline(always)] static fn from_angle_x(radians: f32) -> mat3 { Matrix3::from_angle_x(radians) } + #[inline(always)] static fn from_angle_y(radians: f32) -> mat3 { Matrix3::from_angle_y(radians) } + #[inline(always)] static fn from_angle_z(radians: f32) -> mat3 { Matrix3::from_angle_z(radians) } + #[inline(always)] static fn from_angle_xyz(radians_x: f32, radians_y: f32, radians_z: f32) -> mat3 { Matrix3::from_angle_xyz(radians_x, radians_y, radians_z) } + #[inline(always)] static fn from_angle_axis(radians: f32, axis: &vec3) -> mat3 { Matrix3::from_angle_axis(radians, axis) } + #[inline(always)] static fn from_axes(x: vec3, y: vec3, z: vec3) -> mat3 { Matrix3::from_axes(x, y, z) } + #[inline(always)] static fn look_at(dir: &vec3, up: &vec3) -> mat3 { Matrix3::look_at(dir, up) } - #[inline(always)] static pure fn dim() -> uint { 3 } - #[inline(always)] static pure fn rows() -> uint { 3 } - #[inline(always)] static pure fn cols() -> uint { 3 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 3 } + #[inline(always)] static fn rows() -> uint { 3 } + #[inline(always)] static fn cols() -> uint { 3 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl dmat3 { - #[inline(always)] static pure fn new(c0r0: f64, c0r1: f64, c0r2: f64, c1r0: f64, c1r1: f64, c1r2: f64, c2r0: f64, c2r1: f64, c2r2: f64) + #[inline(always)] static fn new(c0r0: f64, c0r1: f64, c0r2: f64, c1r0: f64, c1r1: f64, c1r2: f64, c2r0: f64, c2r1: f64, c2r2: f64) -> dmat3 { Matrix3::new(c0r0, c0r1, c0r2, c1r0, c1r1, c1r2, c2r0, c2r1, c2r2) } - #[inline(always)] static pure fn from_cols(c0: dvec3, c1: dvec3, c2: dvec3) + #[inline(always)] static fn from_cols(c0: dvec3, c1: dvec3, c2: dvec3) -> dmat3 { Matrix3::from_cols(c0, c1, c2) } - #[inline(always)] static pure fn from_value(v: f64) -> dmat3 { Matrix::from_value(v) } + #[inline(always)] static fn from_value(v: f64) -> dmat3 { Matrix::from_value(v) } - #[inline(always)] static pure fn identity() -> dmat3 { Matrix::identity() } - #[inline(always)] static pure fn zero() -> dmat3 { Matrix::zero() } + #[inline(always)] static fn identity() -> dmat3 { Matrix::identity() } + #[inline(always)] static fn zero() -> dmat3 { Matrix::zero() } - #[inline(always)] static pure fn dim() -> uint { 3 } - #[inline(always)] static pure fn rows() -> uint { 3 } - #[inline(always)] static pure fn cols() -> uint { 3 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 3 } + #[inline(always)] static fn rows() -> uint { 3 } + #[inline(always)] static fn cols() -> uint { 3 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } diff --git a/src/mat4.rs b/src/mat4.rs index 1de82d1..3357390 100644 --- a/src/mat4.rs +++ b/src/mat4.rs @@ -47,10 +47,10 @@ pub struct Mat4 { x: Vec4, y: Vec4, z: Vec4, w: Vec4 } impl + Add + Sub + Mul + Div + Neg> Matrix> for Mat4 { #[inline(always)] - pure fn col(&self, i: uint) -> Vec4 { self[i] } + fn col(&self, i: uint) -> Vec4 { self[i] } #[inline(always)] - pure fn row(&self, i: uint) -> Vec4 { + fn row(&self, i: uint) -> Vec4 { Vector4::new(self[0][i], self[1][i], self[2][i], @@ -78,7 +78,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn from_value(value: T) -> Mat4 { + static fn from_value(value: T) -> Mat4 { Matrix4::new(value, zero(), zero(), zero(), zero(), value, zero(), zero(), zero(), zero(), value, zero(), @@ -101,7 +101,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn identity() -> Mat4 { + static fn identity() -> Mat4 { Matrix4::new( one::(), zero::(), zero::(), zero::(), zero::(), one::(), zero::(), zero::(), zero::(), zero::(), one::(), zero::(), @@ -124,7 +124,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn zero() -> Mat4 { + static fn zero() -> Mat4 { Matrix4::new(zero::(), zero::(), zero::(), zero::(), zero::(), zero::(), zero::(), zero::(), zero::(), zero::(), zero::(), zero::(), @@ -132,7 +132,7 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn mul_t(&self, value: T) -> Mat4 { + fn mul_t(&self, value: T) -> Mat4 { Matrix4::from_cols(self[0].mul_t(value), self[1].mul_t(value), self[2].mul_t(value), @@ -140,7 +140,7 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn mul_v(&self, vec: &Vec4) -> Vec4 { + fn mul_v(&self, vec: &Vec4) -> Vec4 { Vector4::new(self.row(0).dot(vec), self.row(1).dot(vec), self.row(2).dot(vec), @@ -148,7 +148,7 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn add_m(&self, other: &Mat4) -> Mat4 { + fn add_m(&self, other: &Mat4) -> Mat4 { Matrix4::from_cols(self[0].add_v(&other[0]), self[1].add_v(&other[1]), self[2].add_v(&other[2]), @@ -156,7 +156,7 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn sub_m(&self, other: &Mat4) -> Mat4 { + fn sub_m(&self, other: &Mat4) -> Mat4 { Matrix4::from_cols(self[0].sub_v(&other[0]), self[1].sub_v(&other[1]), self[2].sub_v(&other[2]), @@ -164,7 +164,7 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn mul_m(&self, other: &Mat4) -> Mat4 { + fn mul_m(&self, other: &Mat4) -> Mat4 { Matrix4::new(self.row(0).dot(&other.col(0)), self.row(1).dot(&other.col(0)), self.row(2).dot(&other.col(0)), @@ -187,11 +187,11 @@ impl + Add + Sub + Mul + Div + N } - pure fn dot(&self, other: &Mat4) -> T { + fn dot(&self, other: &Mat4) -> T { other.transpose().mul_m(self).trace() } - pure fn determinant(&self) -> T { + fn determinant(&self) -> T { let m0: Mat3 = Matrix3::new(self[1][1], self[2][1], self[3][1], self[1][2], self[2][2], self[3][2], self[1][3], self[2][3], self[3][3]); @@ -211,11 +211,11 @@ impl + Add + Sub + Mul + Div + N self[3][0] * m3.determinant() } - pure fn trace(&self) -> T { + fn trace(&self) -> T { self[0][0] + self[1][1] + self[2][2] + self[3][3] } - pure fn inverse(&self) -> Option> { + fn inverse(&self) -> Option> { let d = self.determinant(); if d.fuzzy_eq(&zero()) { None @@ -262,7 +262,7 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn transpose(&self) -> Mat4 { + fn transpose(&self) -> Mat4 { Matrix4::new(self[0][0], self[1][0], self[2][0], self[3][0], self[0][1], self[1][1], self[2][1], self[3][1], self[0][2], self[1][2], self[2][2], self[3][2], @@ -270,12 +270,12 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn is_identity(&self) -> bool { + fn is_identity(&self) -> bool { self.fuzzy_eq(&Matrix::identity()) } #[inline(always)] - pure fn is_diagonal(&self) -> bool { + fn is_diagonal(&self) -> bool { self[0][1].fuzzy_eq(&zero()) && self[0][2].fuzzy_eq(&zero()) && self[0][3].fuzzy_eq(&zero()) && @@ -294,12 +294,12 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn is_rotated(&self) -> bool { + fn is_rotated(&self) -> bool { !self.fuzzy_eq(&Matrix::identity()) } #[inline(always)] - pure fn is_symmetric(&self) -> bool { + fn is_symmetric(&self) -> bool { self[0][1].fuzzy_eq(&self[1][0]) && self[0][2].fuzzy_eq(&self[2][0]) && self[0][3].fuzzy_eq(&self[3][0]) && @@ -318,12 +318,12 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - pure fn is_invertible(&self) -> bool { + fn is_invertible(&self) -> bool { !self.determinant().fuzzy_eq(&zero()) } #[inline(always)] - pure fn to_ptr(&self) -> *T { + fn to_ptr(&self) -> *T { unsafe { transmute::<*Mat4, *T>( to_unsafe_ptr(self) @@ -357,7 +357,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn new(c0r0: T, c0r1: T, c0r2: T, c0r3: T, + static fn new(c0r0: T, c0r1: T, c0r2: T, c0r3: T, c1r0: T, c1r1: T, c1r2: T, c1r3: T, c2r0: T, c2r1: T, c2r2: T, c2r3: T, c3r0: T, c3r1: T, c3r2: T, c3r3: T) -> Mat4 { @@ -391,7 +391,7 @@ impl + Add + Sub + Mul + Div + N * ~~~ */ #[inline(always)] - static pure fn from_cols(c0: Vec4, + static fn from_cols(c0: Vec4, c1: Vec4, c2: Vec4, c3: Vec4) -> Mat4 { @@ -494,14 +494,14 @@ impl + Add + Sub + Mul + Div + N impl + Add + Sub + Mul + Div + Neg> Neg> for Mat4 { #[inline(always)] - pure fn neg(&self) -> Mat4 { + fn neg(&self) -> Mat4 { Matrix4::from_cols(-self[0], -self[1], -self[2], -self[3]) } } impl Index> for Mat4 { #[inline(always)] - pure fn index(&self, i: uint) -> Vec4 { + fn index(&self, i: uint) -> Vec4 { unsafe { do buf_as_slice( transmute::<*Mat4, *Vec4>( to_unsafe_ptr(self)), 4) |slice| { slice[i] } @@ -511,12 +511,12 @@ impl Index> for Mat4 { impl> FuzzyEq for Mat4 { #[inline(always)] - pure fn fuzzy_eq(&self, other: &Mat4) -> bool { + fn fuzzy_eq(&self, other: &Mat4) -> bool { self.fuzzy_eq_eps(other, &Number::from(FUZZY_EPSILON)) } #[inline(always)] - pure fn fuzzy_eq_eps(&self, other: &Mat4, epsilon: &T) -> bool { + fn fuzzy_eq_eps(&self, other: &Mat4, epsilon: &T) -> bool { self[0].fuzzy_eq_eps(&other[0], epsilon) && self[1].fuzzy_eq_eps(&other[1], epsilon) && self[2].fuzzy_eq_eps(&other[2], epsilon) && @@ -533,33 +533,33 @@ pub type dmat4 = Mat4; // a 4×4 double-precision floating-point matrix // Static method wrappers for GLSL-style types impl mat4 { - #[inline(always)] static pure fn new(c0r0: f32, c0r1: f32, c0r2: f32, c0r3: f32, c1r0: f32, c1r1: f32, c1r2: f32, c1r3: f32, c2r0: f32, c2r1: f32, c2r2: f32, c2r3: f32, c3r0: f32, c3r1: f32, c3r2: f32, c3r3: f32) + #[inline(always)] static fn new(c0r0: f32, c0r1: f32, c0r2: f32, c0r3: f32, c1r0: f32, c1r1: f32, c1r2: f32, c1r3: f32, c2r0: f32, c2r1: f32, c2r2: f32, c2r3: f32, c3r0: f32, c3r1: f32, c3r2: f32, c3r3: f32) -> mat4 { Matrix4::new(c0r0, c0r1, c0r2, c0r3, c1r0, c1r1, c1r2, c1r3, c2r0, c2r1, c2r2, c2r3, c3r0, c3r1, c3r2, c3r3) } - #[inline(always)] static pure fn from_cols(c0: vec4, c1: vec4, c2: vec4, c3: vec4) + #[inline(always)] static fn from_cols(c0: vec4, c1: vec4, c2: vec4, c3: vec4) -> mat4 { Matrix4::from_cols(c0, c1, c2, c3) } - #[inline(always)] static pure fn from_value(v: f32) -> mat4 { Matrix::from_value(v) } + #[inline(always)] static fn from_value(v: f32) -> mat4 { Matrix::from_value(v) } - #[inline(always)] static pure fn identity() -> mat4 { Matrix::identity() } - #[inline(always)] static pure fn zero() -> mat4 { Matrix::zero() } + #[inline(always)] static fn identity() -> mat4 { Matrix::identity() } + #[inline(always)] static fn zero() -> mat4 { Matrix::zero() } - #[inline(always)] static pure fn dim() -> uint { 4 } - #[inline(always)] static pure fn rows() -> uint { 4 } - #[inline(always)] static pure fn cols() -> uint { 4 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 4 } + #[inline(always)] static fn rows() -> uint { 4 } + #[inline(always)] static fn cols() -> uint { 4 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl dmat4 { - #[inline(always)] static pure fn new(c0r0: f64, c0r1: f64, c0r2: f64, c0r3: f64, c1r0: f64, c1r1: f64, c1r2: f64, c1r3: f64, c2r0: f64, c2r1: f64, c2r2: f64, c2r3: f64, c3r0: f64, c3r1: f64, c3r2: f64, c3r3: f64) + #[inline(always)] static fn new(c0r0: f64, c0r1: f64, c0r2: f64, c0r3: f64, c1r0: f64, c1r1: f64, c1r2: f64, c1r3: f64, c2r0: f64, c2r1: f64, c2r2: f64, c2r3: f64, c3r0: f64, c3r1: f64, c3r2: f64, c3r3: f64) -> dmat4 { Matrix4::new(c0r0, c0r1, c0r2, c0r3, c1r0, c1r1, c1r2, c1r3, c2r0, c2r1, c2r2, c2r3, c3r0, c3r1, c3r2, c3r3) } - #[inline(always)] static pure fn from_cols(c0: dvec4, c1: dvec4, c2: dvec4, c3: dvec4) + #[inline(always)] static fn from_cols(c0: dvec4, c1: dvec4, c2: dvec4, c3: dvec4) -> dmat4 { Matrix4::from_cols(c0, c1, c2, c3) } - #[inline(always)] static pure fn from_value(v: f64) -> dmat4 { Matrix::from_value(v) } + #[inline(always)] static fn from_value(v: f64) -> dmat4 { Matrix::from_value(v) } - #[inline(always)] static pure fn identity() -> dmat4 { Matrix::identity() } - #[inline(always)] static pure fn zero() -> dmat4 { Matrix::zero() } + #[inline(always)] static fn identity() -> dmat4 { Matrix::identity() } + #[inline(always)] static fn zero() -> dmat4 { Matrix::zero() } - #[inline(always)] static pure fn dim() -> uint { 4 } - #[inline(always)] static pure fn rows() -> uint { 4 } - #[inline(always)] static pure fn cols() -> uint { 4 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 4 } + #[inline(always)] static fn rows() -> uint { 4 } + #[inline(always)] static fn cols() -> uint { 4 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } diff --git a/src/projection.rs b/src/projection.rs index fb420bf..df1faca 100644 --- a/src/projection.rs +++ b/src/projection.rs @@ -12,7 +12,7 @@ use mat::{Mat4, Matrix4}; * can be found [here](http://www.opengl.org/wiki/GluPerspective_code). */ #[inline(always)] -pub pure fn perspective + Add + Sub + Mul + Div + Neg>(fovy: T, aspectRatio: T, near: T, far: T) -> Mat4 { +pub fn perspective + Add + Sub + Mul + Div + Neg>(fovy: T, aspectRatio: T, near: T, far: T) -> Mat4 { let ymax = near * tan(radians(fovy)); let xmax = ymax * aspectRatio; @@ -26,7 +26,7 @@ pub pure fn perspective + Add + Sub + Mul< * (http://www.opengl.org/sdk/docs/man2/xhtml/glFrustum.xml) function. */ #[inline(always)] -pub pure fn frustum + Add + Sub + Mul + Div + Neg>(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Mat4 { +pub fn frustum + Add + Sub + Mul + Div + Neg>(left: T, right: T, bottom: T, top: T, near: T, far: T) -> Mat4 { let _0: T = Number::from(0); let _1: T = Number::from(1); let _2: T = Number::from(2); diff --git a/src/quat.rs b/src/quat.rs index 6f395b1..e83a7c3 100644 --- a/src/quat.rs +++ b/src/quat.rs @@ -61,7 +61,7 @@ impl + Add + Sub + Mul + Div + N * * `zk` - the third imaginary component */ #[inline(always)] - static pure fn new(w: T, xi: T, yj: T, zk: T) -> Quat { + static fn new(w: T, xi: T, yj: T, zk: T) -> Quat { Quat::from_sv(w, Vector3::new(xi, yj, zk)) } @@ -74,7 +74,7 @@ impl + Add + Sub + Mul + Div + N * * `v` - a vector containing the three imaginary components */ #[inline(always)] - static pure fn from_sv(s: T, v: Vec3) -> Quat { + static fn from_sv(s: T, v: Vec3) -> Quat { Quat { s: s, v: v } } @@ -84,7 +84,7 @@ impl + Add + Sub + Mul + Div + N * The multiplicative identity, ie: `q = 1 + 0i + 0j + 0i` */ #[inline(always)] - static pure fn identity() -> Quat { + static fn identity() -> Quat { Quat::new(one(), zero(), zero(), zero()) } @@ -94,30 +94,30 @@ impl + Add + Sub + Mul + Div + N * The additive identity, ie: `q = 0 + 0i + 0j + 0i` */ #[inline(always)] - static pure fn zero() -> Quat { + static fn zero() -> Quat { Quat::new(zero(), zero(), zero(), zero()) } #[inline(always)] - static pure fn from_angle_x(radians: T) -> Quat { + static fn from_angle_x(radians: T) -> Quat { let _2 = Number::from(2); Quat::new(cos(radians / _2), sin(radians), zero(), zero()) } #[inline(always)] - static pure fn from_angle_y(radians: T) -> Quat { + static fn from_angle_y(radians: T) -> Quat { let _2 = Number::from(2); Quat::new(cos(radians / _2), zero(), sin(radians), zero()) } #[inline(always)] - static pure fn from_angle_z(radians: T) -> Quat { + static fn from_angle_z(radians: T) -> Quat { let _2 = Number::from(2); Quat::new(cos(radians / _2), zero(), zero(), sin(radians)) } #[inline(always)] - static pure fn from_angle_xyz(radians_x: T, radians_y: T, radians_z: T) -> Quat { + static fn from_angle_xyz(radians_x: T, radians_y: T, radians_z: T) -> Quat { // http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles#Conversion let _2 = Number::from(2); let xdiv2 = radians_x / _2; @@ -130,22 +130,22 @@ impl + Add + Sub + Mul + Div + N } #[inline(always)] - static pure fn from_angle_axis(radians: T, axis: &Vec3) -> Quat { + static fn from_angle_axis(radians: T, axis: &Vec3) -> Quat { let half = radians / Number::from(2); Quat::from_sv(cos(half), axis.mul_t(sin(half))) } #[inline(always)] - static pure fn from_axes(x: Vec3, y: Vec3, z: Vec3) -> Quat { + static fn from_axes(x: Vec3, y: Vec3, z: Vec3) -> Quat { let m: Mat3 = Matrix3::from_axes(x, y, z); m.to_quat() } - pure fn get_angle_axis(&self) -> (T, Vec3) { + fn get_angle_axis(&self) -> (T, Vec3) { fail!(~"Not yet implemented.") } #[inline(always)] - static pure fn look_at(dir: &Vec3, up: &Vec3) -> Quat { + static fn look_at(dir: &Vec3, up: &Vec3) -> Quat { let m: Mat3 = Matrix3::look_at(dir, up); m.to_quat() } @@ -155,7 +155,7 @@ impl + Add + Sub + Mul + Div + N * The result of multiplying the quaternion a scalar */ #[inline(always)] - pure fn mul_t(&self, value: T) -> Quat { + fn mul_t(&self, value: T) -> Quat { Quat::new(self[0] * value, self[1] * value, self[2] * value, @@ -168,7 +168,7 @@ impl + Add + Sub + Mul + Div + N * The result of dividing the quaternion a scalar */ #[inline(always)] - pure fn div_t(&self, value: T) -> Quat { + fn div_t(&self, value: T) -> Quat { Quat::new(self[0] / value, self[1] / value, self[2] / value, @@ -181,7 +181,7 @@ impl + Add + Sub + Mul + Div + N * The result of multiplying the quaternion by a vector */ #[inline(always)] - pure fn mul_v(&self, vec: &Vec3) -> Vec3 { + fn mul_v(&self, vec: &Vec3) -> Vec3 { let tmp = self.v.cross(vec).add_v(&vec.mul_t(self.s)); self.v.cross(&tmp).mul_t(Number::from(2)).add_v(vec) } @@ -192,7 +192,7 @@ impl + Add + Sub + Mul + Div + N * The sum of this quaternion and `other` */ #[inline(always)] - pure fn add_q(&self, other: &Quat) -> Quat { + fn add_q(&self, other: &Quat) -> Quat { Quat::new(self[0] + other[0], self[1] + other[1], self[2] + other[2], @@ -205,7 +205,7 @@ impl + Add + Sub + Mul + Div + N * The sum of this quaternion and `other` */ #[inline(always)] - pure fn sub_q(&self, other: &Quat) -> Quat { + fn sub_q(&self, other: &Quat) -> Quat { Quat::new(self[0] - other[0], self[1] - other[1], self[2] - other[2], @@ -218,7 +218,7 @@ impl + Add + Sub + Mul + Div + N * The the result of multipliplying the quaternion by `other` */ #[inline(always)] - pure fn mul_q(&self, other: &Quat) -> Quat { + fn mul_q(&self, other: &Quat) -> Quat { Quat::new(self.s * other.s - self.v.x * other.v.x - self.v.y * other.v.y - self.v.z * other.v.z, self.s * other.v.x + self.v.x * other.s + self.v.y * other.v.z - self.v.z * other.v.y, self.s * other.v.y + self.v.y * other.s + self.v.z * other.v.x - self.v.x * other.v.z, @@ -231,7 +231,7 @@ impl + Add + Sub + Mul + Div + N * The dot product of the quaternion and `other` */ #[inline(always)] - pure fn dot(&self, other: &Quat) -> T { + fn dot(&self, other: &Quat) -> T { self.s * other.s + self.v.dot(&other.v) } @@ -241,7 +241,7 @@ impl + Add + Sub + Mul + Div + N * The conjugate of the quaternion */ #[inline(always)] - pure fn conjugate(&self) -> Quat { + fn conjugate(&self) -> Quat { Quat::from_sv(self.s, -self.v) } @@ -251,7 +251,7 @@ impl + Add + Sub + Mul + Div + N * The multiplicative inverse of the quaternion */ #[inline(always)] - pure fn inverse(&self) -> Quat { + fn inverse(&self) -> Quat { self.conjugate().div_t(self.magnitude2()) } @@ -263,7 +263,7 @@ impl + Add + Sub + Mul + Div + N * calculated. */ #[inline(always)] - pure fn magnitude2(&self) -> T { + fn magnitude2(&self) -> T { self.s * self.s + self.v.length2() } @@ -279,7 +279,7 @@ impl + Add + Sub + Mul + Div + N * it is advisable to use the `magnitude2` method instead. */ #[inline(always)] - pure fn magnitude(&self) -> T { + fn magnitude(&self) -> T { self.magnitude2().sqrt() } @@ -289,7 +289,7 @@ impl + Add + Sub + Mul + Div + N * The normalized quaternion */ #[inline(always)] - pure fn normalize(&self) -> Quat { + fn normalize(&self) -> Quat { self.mul_t(one::()/self.magnitude()) } @@ -301,7 +301,7 @@ impl + Add + Sub + Mul + Div + N * The intoperlated quaternion */ #[inline(always)] - pure fn nlerp(&self, other: &Quat, amount: T) -> Quat { + fn nlerp(&self, other: &Quat, amount: T) -> Quat { self.mul_t(one::() - amount).add_q(&other.mul_t(amount)).normalize() } @@ -327,7 +327,7 @@ impl + Add + Sub + Mul + Div + N * (http://www.arcsynthesis.org/gltut/Positioning/Tut08%20Interpolation.html) */ #[inline(always)] - pure fn slerp(&self, other: &Quat, amount: T) -> Quat { + fn slerp(&self, other: &Quat, amount: T) -> Quat { let dot = self.dot(other); let dot_threshold = Number::from(0.9995); @@ -353,7 +353,7 @@ impl + Add + Sub + Mul + Div + N * A pointer to the first component of the quaternion */ #[inline(always)] - pure fn to_ptr(&self) -> *T { + fn to_ptr(&self) -> *T { unsafe { transmute::<*Quat, *T>( to_unsafe_ptr(self) @@ -365,7 +365,7 @@ impl + Add + Sub + Mul + Div + N * Convert the quaternion to a 3 x 3 rotation matrix */ #[inline(always)] - pure fn to_mat3(&self) -> Mat3 { + fn to_mat3(&self) -> Mat3 { let x2 = self.v.x + self.v.x; let y2 = self.v.y + self.v.y; let z2 = self.v.z + self.v.z; @@ -392,7 +392,7 @@ impl + Add + Sub + Mul + Div + N impl Index for Quat { #[inline(always)] - pure fn index(&self, i: uint) -> T { + fn index(&self, i: uint) -> T { unsafe { do buf_as_slice( transmute::<*Quat, *T>( to_unsafe_ptr(self)), 4) |slice| { slice[i] } @@ -402,19 +402,19 @@ impl Index for Quat { impl + Add + Sub + Mul + Div + Neg> Neg> for Quat { #[inline(always)] - pure fn neg(&self) -> Quat { + fn neg(&self) -> Quat { Quat::new(-self[0], -self[1], -self[2], -self[3]) } } impl> FuzzyEq for Quat { #[inline(always)] - pure fn fuzzy_eq(&self, other: &Quat) -> bool { + fn fuzzy_eq(&self, other: &Quat) -> bool { self.fuzzy_eq_eps(other, &Number::from(FUZZY_EPSILON)) } #[inline(always)] - pure fn fuzzy_eq_eps(&self, other: &Quat, epsilon: &T) -> bool { + fn fuzzy_eq_eps(&self, other: &Quat, epsilon: &T) -> bool { self[0].fuzzy_eq_eps(&other[0], epsilon) && self[1].fuzzy_eq_eps(&other[1], epsilon) && self[2].fuzzy_eq_eps(&other[2], epsilon) && @@ -431,33 +431,33 @@ pub type dquat = Quat; /// a double-precision floating-point qu // Static method wrappers for GLSL-style types impl quat { - #[inline(always)] static pure fn new(w: f32, xi: f32, yj: f32, zk: f32) -> quat { Quat::new(w, xi, yj, zk) } - #[inline(always)] static pure fn from_sv(s: f32, v: vec3) -> quat { Quat::from_sv(s, v) } - #[inline(always)] static pure fn identity() -> quat { Quat::identity() } - #[inline(always)] static pure fn zero() -> quat { Quat::zero() } + #[inline(always)] static fn new(w: f32, xi: f32, yj: f32, zk: f32) -> quat { Quat::new(w, xi, yj, zk) } + #[inline(always)] static fn from_sv(s: f32, v: vec3) -> quat { Quat::from_sv(s, v) } + #[inline(always)] static fn identity() -> quat { Quat::identity() } + #[inline(always)] static fn zero() -> quat { Quat::zero() } - #[inline(always)] static pure fn from_angle_x(radians: f32) -> quat { Quat::from_angle_x(radians) } - #[inline(always)] static pure fn from_angle_y(radians: f32) -> quat { Quat::from_angle_y(radians) } - #[inline(always)] static pure fn from_angle_z(radians: f32) -> quat { Quat::from_angle_z(radians) } - #[inline(always)] static pure fn from_angle_xyz(radians_x: f32, radians_y: f32, radians_z: f32) + #[inline(always)] static fn from_angle_x(radians: f32) -> quat { Quat::from_angle_x(radians) } + #[inline(always)] static fn from_angle_y(radians: f32) -> quat { Quat::from_angle_y(radians) } + #[inline(always)] static fn from_angle_z(radians: f32) -> quat { Quat::from_angle_z(radians) } + #[inline(always)] static fn from_angle_xyz(radians_x: f32, radians_y: f32, radians_z: f32) -> quat { Quat::from_angle_xyz(radians_x, radians_y, radians_z) } - #[inline(always)] static pure fn from_angle_axis(radians: f32, axis: &vec3) -> quat { Quat::from_angle_axis(radians, axis) } - #[inline(always)] static pure fn from_axes(x: vec3, y: vec3, z: vec3) -> quat { Quat::from_axes(x, y, z) } - #[inline(always)] static pure fn look_at(dir: &vec3, up: &vec3) -> quat { Quat::look_at(dir, up) } + #[inline(always)] static fn from_angle_axis(radians: f32, axis: &vec3) -> quat { Quat::from_angle_axis(radians, axis) } + #[inline(always)] static fn from_axes(x: vec3, y: vec3, z: vec3) -> quat { Quat::from_axes(x, y, z) } + #[inline(always)] static fn look_at(dir: &vec3, up: &vec3) -> quat { Quat::look_at(dir, up) } } impl dquat { - #[inline(always)] static pure fn new(w: f64, xi: f64, yj: f64, zk: f64) -> dquat { Quat::new(w, xi, yj, zk) } - #[inline(always)] static pure fn from_sv(s: f64, v: dvec3) -> dquat { Quat::from_sv(s, v) } - #[inline(always)] static pure fn identity() -> dquat { Quat::identity() } - #[inline(always)] static pure fn zero() -> dquat { Quat::zero() } + #[inline(always)] static fn new(w: f64, xi: f64, yj: f64, zk: f64) -> dquat { Quat::new(w, xi, yj, zk) } + #[inline(always)] static fn from_sv(s: f64, v: dvec3) -> dquat { Quat::from_sv(s, v) } + #[inline(always)] static fn identity() -> dquat { Quat::identity() } + #[inline(always)] static fn zero() -> dquat { Quat::zero() } - #[inline(always)] static pure fn from_angle_x(radians: f64) -> dquat { Quat::from_angle_x(radians) } - #[inline(always)] static pure fn from_angle_y(radians: f64) -> dquat { Quat::from_angle_y(radians) } - #[inline(always)] static pure fn from_angle_z(radians: f64) -> dquat { Quat::from_angle_z(radians) } - #[inline(always)] static pure fn from_angle_xyz(radians_x: f64, radians_y: f64, radians_z: f64) + #[inline(always)] static fn from_angle_x(radians: f64) -> dquat { Quat::from_angle_x(radians) } + #[inline(always)] static fn from_angle_y(radians: f64) -> dquat { Quat::from_angle_y(radians) } + #[inline(always)] static fn from_angle_z(radians: f64) -> dquat { Quat::from_angle_z(radians) } + #[inline(always)] static fn from_angle_xyz(radians_x: f64, radians_y: f64, radians_z: f64) -> dquat { Quat::from_angle_xyz(radians_x, radians_y, radians_z) } - #[inline(always)] static pure fn from_angle_axis(radians: f64, axis: &dvec3) -> dquat { Quat::from_angle_axis(radians, axis) } - #[inline(always)] static pure fn from_axes(x: dvec3, y: dvec3, z: dvec3) -> dquat { Quat::from_axes(x, y, z) } - #[inline(always)] static pure fn look_at(dir: &dvec3, up: &dvec3) -> dquat { Quat::look_at(dir, up) } + #[inline(always)] static fn from_angle_axis(radians: f64, axis: &dvec3) -> dquat { Quat::from_angle_axis(radians, axis) } + #[inline(always)] static fn from_axes(x: dvec3, y: dvec3, z: dvec3) -> dquat { Quat::from_axes(x, y, z) } + #[inline(always)] static fn look_at(dir: &dvec3, up: &dvec3) -> dquat { Quat::look_at(dir, up) } } diff --git a/src/test/performance/matrix_mul.rs b/src/test/performance/matrix_mul.rs index df917fd..7b740a4 100644 --- a/src/test/performance/matrix_mul.rs +++ b/src/test/performance/matrix_mul.rs @@ -79,14 +79,14 @@ pub struct Vec4 { x: float, y: float, z: float, w: float } mod Vec4 { #[inline(always)] - pub pure fn new(x: float, y: float, z: float, w: float) -> Vec4 { + pub fn new(x: float, y: float, z: float, w: float) -> Vec4 { Vec4 { x: move x, y: move y, z: move z, w: move w } } } impl Vec4 { #[inline(always)] - pure fn dot(other: &Vec4) -> float { + fn dot(other: &Vec4) -> float { self[0] * other[0] + self[1] * other[1] + self[2] * other[2] + @@ -96,7 +96,7 @@ impl Vec4 { pub impl Vec4: Index { #[inline(always)] - pure fn index(i: uint) -> float { + fn index(i: uint) -> float { unsafe { do buf_as_slice( transmute::<*Vec4, *float>( to_unsafe_ptr(&self)), 4) |slice| { slice[i] } @@ -106,7 +106,7 @@ pub impl Vec4: Index { pub impl Vec4: Eq { #[inline(always)] - pure fn eq(other: &Vec4) -> bool { + fn eq(other: &Vec4) -> bool { self[0] == other [0] && self[1] == other [1] && self[2] == other [2] && @@ -114,7 +114,7 @@ pub impl Vec4: Eq { } #[inline(always)] - pure fn ne(other: &Vec4) -> bool { + fn ne(other: &Vec4) -> bool { !(self == *other) } } @@ -125,7 +125,7 @@ pub struct Mat4 { x: Vec4, y: Vec4, z: Vec4, w: Vec4 } mod Mat4 { #[inline(always)] - pub pure fn new(c0r0: float, c0r1: float, c0r2: float, c0r3: float, + pub fn new(c0r0: float, c0r1: float, c0r2: float, c0r3: float, c1r0: float, c1r1: float, c1r2: float, c1r3: float, c2r0: float, c2r1: float, c2r2: float, c2r3: float, c3r0: float, c3r1: float, c3r2: float, c3r3: float) -> Mat4 { @@ -136,7 +136,7 @@ mod Mat4 { } #[inline(always)] - pub pure fn from_cols(c0: Vec4, c1: Vec4, c2: Vec4, c3: Vec4) -> Mat4 { + pub fn from_cols(c0: Vec4, c1: Vec4, c2: Vec4, c3: Vec4) -> Mat4 { Mat4 { x: move c0, y: move c1, z: move c2, @@ -146,17 +146,17 @@ mod Mat4 { impl Mat4 { #[inline(always)] - pure fn col(i: uint) -> Vec4 { self[i] } + fn col(i: uint) -> Vec4 { self[i] } #[inline(always)] - pure fn row(i: uint) -> Vec4 { + fn row(i: uint) -> Vec4 { Vec4::new(self[0][i], self[1][i], self[2][i], self[3][i]) } - pure fn mul_matrix_expanded(other: &Mat4) -> Mat4 { + fn mul_matrix_expanded(other: &Mat4) -> Mat4 { Mat4::new(self[0][0] * other[0][0] + self[1][0] * other[0][1] + self[2][0] * other[0][2] + self[3][0] * other[0][3], self[0][1] * other[0][0] + self[1][1] * other[0][1] + self[2][1] * other[0][2] + self[3][1] * other[0][3], self[0][2] * other[0][0] + self[1][2] * other[0][1] + self[2][2] * other[0][2] + self[3][2] * other[0][3], @@ -178,7 +178,7 @@ impl Mat4 { self[0][3] * other[3][0] + self[1][3] * other[3][1] + self[2][3] * other[3][2] + self[3][3] * other[3][3]) } - pure fn mul_matrix_dot_product(other: &Mat4) -> Mat4 { + fn mul_matrix_dot_product(other: &Mat4) -> Mat4 { Mat4::new(self.row(0).dot(&other.col(0)), self.row(1).dot(&other.col(0)), self.row(2).dot(&other.col(0)), self.row(3).dot(&other.col(0)), self.row(0).dot(&other.col(1)), self.row(1).dot(&other.col(1)), self.row(2).dot(&other.col(1)), self.row(3).dot(&other.col(1)), self.row(0).dot(&other.col(2)), self.row(1).dot(&other.col(2)), self.row(2).dot(&other.col(2)), self.row(3).dot(&other.col(2)), @@ -188,7 +188,7 @@ impl Mat4 { pub impl Mat4: Index { #[inline(always)] - pure fn index(i: uint) -> Vec4 { + fn index(i: uint) -> Vec4 { unsafe { do buf_as_slice( transmute::<*Mat4, *Vec4>( to_unsafe_ptr(&self)), 4) |slice| { slice[i] } @@ -198,7 +198,7 @@ pub impl Mat4: Index { pub impl Mat4: Eq { #[inline(always)] - pure fn eq(other: &Mat4) -> bool { + fn eq(other: &Mat4) -> bool { self[0] == other [0] && self[1] == other [1] && self[2] == other [2] && @@ -206,7 +206,7 @@ pub impl Mat4: Eq { } #[inline(always)] - pure fn ne(other: &Mat4) -> bool { + fn ne(other: &Mat4) -> bool { !(self == *other) } } diff --git a/src/test/performance/vector_index_operator.rs b/src/test/performance/vector_index_operator.rs index 023a671..d0960ff 100644 --- a/src/test/performance/vector_index_operator.rs +++ b/src/test/performance/vector_index_operator.rs @@ -15,7 +15,7 @@ pub struct VecMatch { x: float, y: float, z: float, w: float } pub impl VecMatch: Index { #[inline(always)] - pure fn index(i: uint) -> float { + fn index(i: uint) -> float { match i { 0 => self.x, 1 => self.y, @@ -30,7 +30,7 @@ pub struct VecReinterpret { x: float, y: float, z: float, w: float } pub impl VecReinterpret: Index { #[inline(always)] - pure fn index(i: uint) -> float unsafe { + fn index(i: uint) -> float unsafe { (reinterpret_cast::(&self))[i] } } @@ -39,7 +39,7 @@ pub struct VecTransmute { x: float, y: float, z: float, w: float } pub impl VecTransmute: Index { #[inline(always)] - pure fn index(i: uint) -> float unsafe { + fn index(i: uint) -> float unsafe { (transmute::(self))[i] } } @@ -48,7 +48,7 @@ pub struct VecBufSlice { x: float, y: float, z: float, w: float } pub impl VecBufSlice: Index { #[inline(always)] - pure fn index(i: uint) -> float unsafe { + fn index(i: uint) -> float unsafe { do vec::raw::buf_as_slice( transmute::<*VecBufSlice, *float>( to_unsafe_ptr(&self)), 4) |slice| { slice[i] } diff --git a/src/test/performance/vector_map_fold.rs b/src/test/performance/vector_map_fold.rs index c61bfb5..61d56c6 100644 --- a/src/test/performance/vector_map_fold.rs +++ b/src/test/performance/vector_map_fold.rs @@ -18,14 +18,14 @@ pub struct Vec4 { x: T, y: T, z: T, w: T } pub mod Vec4 { #[inline(always)] - pub pure fn new(x: T, y: T, z: T, w: T) -> Vec4 { + pub fn new(x: T, y: T, z: T, w: T) -> Vec4 { Vec4 { x: move x, y: move y, z: move z, w: move w } } } pub impl Vec4 { #[inline(always)] - pure fn index(i: uint) -> T { + fn index(i: uint) -> T { unsafe { do buf_as_slice( transmute::<*Vec4, *T>( to_unsafe_ptr(&self)), 4) |slice| { slice[i] } @@ -35,7 +35,7 @@ pub impl Vec4 { //////////////////////////////////////////////////////////////////////////// #[inline(always)] - pure fn map(f: fn&(a: &T) -> T) -> Vec4 { + fn map(f: fn&(a: &T) -> T) -> Vec4 { Vec4::new(f(&self[0]), f(&self[1]), f(&self[2]), @@ -43,24 +43,24 @@ pub impl Vec4 { } #[inline(always)] - pure fn map2(other: &Vec4, f: fn&(a: &T, b: &T) -> T) -> Vec4 { + fn map2(other: &Vec4, f: fn&(a: &T, b: &T) -> T) -> Vec4 { Vec4::new(f(&self[0], &other[0]), f(&self[1], &other[1]), f(&self[2], &other[2]), f(&self[3], &other[3])) } - pure fn foldl(z: U, p: &fn(t: T, u: &U) -> U) -> U { + fn foldl(z: U, p: &fn(t: T, u: &U) -> U) -> U { p(self[3], &p(self[2], &p(self[1], &p(self[0], &z)))) } - pure fn foldr(z: U, p: &fn(t: &T, u: U) -> U) -> U { + fn foldr(z: U, p: &fn(t: &T, u: U) -> U) -> U { p(&self[0], p(&self[1], p(&self[2], p(&self[3], z)))) } //////////////////////////////////////////////////////////////////////////// #[inline(always)] - pure fn mul_t(value: T) -> Vec4 { + fn mul_t(value: T) -> Vec4 { Vec4::new(self[0] * value, self[1] * value, self[2] * value, @@ -68,12 +68,12 @@ pub impl Vec4 { } #[inline(always)] - pure fn mul_t_map(value: T) -> Vec4 { + fn mul_t_map(value: T) -> Vec4 { do self.map |a| { a * value } } #[inline(always)] - pure fn add_v(other: &Vec4) -> Vec4 { + fn add_v(other: &Vec4) -> Vec4 { Vec4::new(self[0] + other[0], self[1] + other[1], self[2] + other[2], @@ -81,12 +81,12 @@ pub impl Vec4 { } #[inline(always)] - pure fn add_v_map2(other: &Vec4) -> Vec4 { + fn add_v_map2(other: &Vec4) -> Vec4 { do self.map2(other) |a, b| { a + *b } } #[inline(always)] - pure fn dot(other: &Vec4) -> T { + fn dot(other: &Vec4) -> T { self[0] * other[0] + self[1] * other[1] + self[2] * other[2] + @@ -94,7 +94,7 @@ pub impl Vec4 { } #[inline(always)] - pure fn dot_foldl(other: &Vec4) -> T { + fn dot_foldl(other: &Vec4) -> T { self.map2(other, |a, b| { a * *b }) .foldl(from_int(0), |t, u| { t + *u }) } @@ -102,7 +102,7 @@ pub impl Vec4 { pub impl Vec4: Eq { #[inline(always)] - pure fn eq(other: &Vec4) -> bool { + fn eq(other: &Vec4) -> bool { self[0] == other[0] && self[1] == other[1] && self[2] == other[2] && @@ -110,7 +110,7 @@ pub impl Vec4: Eq { } #[inline(always)] - pure fn ne(other: &Vec4) -> bool { + fn ne(other: &Vec4) -> bool { !(self == *other) } } diff --git a/src/vec.rs b/src/vec.rs index 763fe5f..7e11c04 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -21,14 +21,14 @@ pub trait Vector: Index + Eq { /** * Construct the vector from a single value, copying it to each component */ - static pure fn from_value(value: T) -> Self; + static fn from_value(value: T) -> Self; /** * # Return value * * A pointer to the first component of the vector */ - pure fn to_ptr(&self) -> *T; + fn to_ptr(&self) -> *T; } pub trait MutableVector: Vector { @@ -47,21 +47,21 @@ pub trait MutableVector: Vector { * A generic 2-dimensional vector */ pub trait Vector2: Vector { - static pure fn new(x: T, y: T) -> Self; + static fn new(x: T, y: T) -> Self; } /** * A generic 3-dimensional vector */ pub trait Vector3: Vector { - static pure fn new(x: T, y: T, z: T) -> Self; + static fn new(x: T, y: T, z: T) -> Self; } /** * A generic 4-dimensional vector */ pub trait Vector4: Vector { - static pure fn new(x: T, y: T, z: T, w: T) -> Self; + static fn new(x: T, y: T, z: T, w: T) -> Self; } /** @@ -75,7 +75,7 @@ pub trait NumericVector: Vector + Neg { * * A vector with each component set to one */ - static pure fn identity() -> Self; + static fn identity() -> Self; /** * The null vector @@ -84,96 +84,96 @@ pub trait NumericVector: Vector + Neg { * * A vector with each component set to zero */ - static pure fn zero() -> Self; + static fn zero() -> Self; /** * # Return value * * True if the vector is equal to zero */ - pure fn is_zero(&self) -> bool; + fn is_zero(&self) -> bool; /** * # Return value * * The scalar multiplication of the vector and `value` */ - pure fn mul_t(&self, value: T) -> Self; + fn mul_t(&self, value: T) -> Self; /** * # Return value * * The scalar division of the vector and `value` */ - pure fn div_t(&self, value: T) -> Self; + fn div_t(&self, value: T) -> Self; /** * Component-wise vector addition */ - pure fn add_v(&self, other: &Self) -> Self; + fn add_v(&self, other: &Self) -> Self; /** * Component-wise vector subtraction */ - pure fn sub_v(&self, other: &Self) -> Self; + fn sub_v(&self, other: &Self) -> Self; /** * Component-wise vector multiplication */ - pure fn mul_v(&self, other: &Self) -> Self; + fn mul_v(&self, other: &Self) -> Self; /** * Component-wise vector division */ - pure fn div_v(&self, other: &Self) -> Self; + fn div_v(&self, other: &Self) -> Self; /** * # Return value * * The dot product of the vector and `other` */ - pure fn dot(&self, other: &Self) -> T; + fn dot(&self, other: &Self) -> T; } /** * A 2-dimensional vector with numeric components */ pub trait NumericVector2: NumericVector { - static pure fn unit_x() -> Self; - static pure fn unit_y() -> Self; + static fn unit_x() -> Self; + static fn unit_y() -> Self; /** * # Return value * * The perp dot product of the vector and `other` */ - pure fn perp_dot(&self, other: &Self) -> T; + fn perp_dot(&self, other: &Self) -> T; } /** * A 3-dimensional vector with numeric components */ pub trait NumericVector3: NumericVector { - static pure fn unit_x() -> Self; - static pure fn unit_y() -> Self; - static pure fn unit_z() -> Self; + static fn unit_x() -> Self; + static fn unit_y() -> Self; + static fn unit_z() -> Self; /** * # Return value * * The cross product of the vector and `other` */ - pure fn cross(&self, other: &Self) -> Self; + fn cross(&self, other: &Self) -> Self; } /** * A 4-dimensional vector with numeric components */ pub trait NumericVector4: NumericVector { - static pure fn unit_x() -> Self; - static pure fn unit_y() -> Self; - static pure fn unit_z() -> Self; - static pure fn unit_w() -> Self; + static fn unit_x() -> Self; + static fn unit_y() -> Self; + static fn unit_z() -> Self; + static fn unit_w() -> Self; } /** @@ -231,7 +231,7 @@ pub trait ToHomogeneous { /** * Convert to a homogenous coordinate */ - pure fn to_homogeneous(&self) -> H; + fn to_homogeneous(&self) -> H; } /** @@ -248,7 +248,7 @@ pub trait EuclideanVector: NumericVector { * The squared length of the vector. This is useful for comparisons where * the exact length does not need to be calculated. */ - pure fn length2(&self) -> T; + fn length2(&self) -> T; /** * # Return value @@ -261,40 +261,40 @@ pub trait EuclideanVector: NumericVector { * known, for example for quaternion-quaternion length comparisons, * it is advisable to use the `length2` method instead. */ - pure fn length(&self) -> T; + fn length(&self) -> T; /** * # Return value * * The squared distance between the vector and `other`. */ - pure fn distance2(&self, other: &Self) -> T; + fn distance2(&self, other: &Self) -> T; /** * # Return value * * The distance between the vector and `other` */ - pure fn distance(&self, other: &Self) -> T; + fn distance(&self, other: &Self) -> T; /** * # Return value * * The angle between the vector and `other` in radians */ - pure fn angle(&self, other: &Self) -> T; + fn angle(&self, other: &Self) -> T; /** * # Return value * * The normalized vector */ - pure fn normalize(&self) -> Self; + fn normalize(&self) -> Self; /** * Set the length of the vector whilst preserving the direction */ - pure fn normalize_to(&self, length: T) -> Self; + fn normalize_to(&self, length: T) -> Self; /** * Linearly intoperlate between the vector and `other` @@ -303,7 +303,7 @@ pub trait EuclideanVector: NumericVector { * * The intoperlated vector */ - pure fn lerp(&self, other: &Self, amount: T) -> Self; + fn lerp(&self, other: &Self, amount: T) -> Self; } /** @@ -342,22 +342,22 @@ pub trait OrdinalVector: Vector { /** * Component-wise compare of `self < other` */ - pure fn less_than(&self, other: &Self) -> BoolVec; + fn less_than(&self, other: &Self) -> BoolVec; /** * Component-wise compare of `self <= other` */ - pure fn less_than_equal(&self, other: &Self) -> BoolVec; + fn less_than_equal(&self, other: &Self) -> BoolVec; /** * Component-wise compare of `self > other` */ - pure fn greater_than(&self, other: &Self) -> BoolVec; + fn greater_than(&self, other: &Self) -> BoolVec; /** * Component-wise compare of `self >= other` */ - pure fn greater_than_equal(&self, other: &Self) -> BoolVec; + fn greater_than_equal(&self, other: &Self) -> BoolVec; } /** @@ -371,12 +371,12 @@ pub trait EquableVector: Vector { /** * Component-wise compare of `self == other` */ - pure fn equal(&self, other: &Self) -> BoolVec; + fn equal(&self, other: &Self) -> BoolVec; /** * Component-wise compare of `self != other` */ - pure fn not_equal(&self, other: &Self) -> BoolVec; + fn not_equal(&self, other: &Self) -> BoolVec; } /** @@ -392,93 +392,93 @@ pub trait BooleanVector: Vector { * * `true` if of any component is `true` */ - pure fn any(&self) -> bool; + fn any(&self) -> bool; /** * # Return value * * `true` only if all components are `true` */ - pure fn all(&self) -> bool; + fn all(&self) -> bool; /** * # Return value * * the component-wise logical complement */ - pure fn not(&self) -> Self; + fn not(&self) -> Self; } pub trait TrigVec: Vector { - pure fn radians(&self) -> Self; - pure fn degrees(&self) -> Self; + fn radians(&self) -> Self; + fn degrees(&self) -> Self; // Triganometric functions - pure fn sin(&self) -> Self; - pure fn cos(&self) -> Self; - pure fn tan(&self) -> Self; + fn sin(&self) -> Self; + fn cos(&self) -> Self; + fn tan(&self) -> Self; // Inverse triganometric functions - pure fn asin(&self) -> Self; - pure fn acos(&self) -> Self; - pure fn atan(&self) -> Self; - pure fn atan2(&self, other: Self) -> Self; + fn asin(&self) -> Self; + fn acos(&self) -> Self; + fn atan(&self) -> Self; + fn atan2(&self, other: Self) -> Self; // Hyperbolic triganometric functions - pure fn sinh(&self) -> Self; - pure fn cosh(&self) -> Self; - pure fn tanh(&self) -> Self; - // pure fn asinh() -> Self; - // pure fn acosh() -> Self; - // pure fn atanh() -> Self; + fn sinh(&self) -> Self; + fn cosh(&self) -> Self; + fn tanh(&self) -> Self; + // fn asinh() -> Self; + // fn acosh() -> Self; + // fn atanh() -> Self; } pub trait ExpVec: Vector { // Exponential functions - pure fn pow_t(&self, n: Self) -> Self; - pure fn pow_v(&self, n: T) -> Self; - pure fn exp(&self) -> Self; - pure fn exp2(&self) -> Self; - pure fn ln(&self) -> Self; - pure fn ln2(&self) -> Self; - pure fn sqrt(&self) -> Self; - pure fn inv_sqrt(&self) -> Self; + fn pow_t(&self, n: Self) -> Self; + fn pow_v(&self, n: T) -> Self; + fn exp(&self) -> Self; + fn exp2(&self) -> Self; + fn ln(&self) -> Self; + fn ln2(&self) -> Self; + fn sqrt(&self) -> Self; + fn inv_sqrt(&self) -> Self; } pub trait ApproxVec: Vector { // Whole-number approximation functions - pure fn floor(&self) -> Self; - pure fn trunc(&self) -> Self; - pure fn round(&self) -> Self; - // pure fn round_even(&self) -> Self; - pure fn ceil(&self) -> Self; - pure fn fract(&self) -> Self; + fn floor(&self) -> Self; + fn trunc(&self) -> Self; + fn round(&self) -> Self; + // fn round_even(&self) -> Self; + fn ceil(&self) -> Self; + fn fract(&self) -> Self; } pub trait SignedVec: Vector { - pure fn is_positive(&self) -> BV; - pure fn is_negative(&self) -> BV; - pure fn is_nonpositive(&self) -> BV; - pure fn is_nonnegative(&self) -> BV; + fn is_positive(&self) -> BV; + fn is_negative(&self) -> BV; + fn is_nonpositive(&self) -> BV; + fn is_nonnegative(&self) -> BV; - pure fn abs(&self) -> Self; - pure fn sign(&self) -> Self; - pure fn copysign(&self, other: Self) -> Self; + fn abs(&self) -> Self; + fn sign(&self) -> Self; + fn copysign(&self, other: Self) -> Self; } pub trait ExtentVec: Vector { - pure fn min_v(&self, other: &Self) -> Self; - pure fn max_v(&self, other: &Self) -> Self; - pure fn clamp_v(&self, mn: &Self, mx: &Self) -> Self; + fn min_v(&self, other: &Self) -> Self; + fn max_v(&self, other: &Self) -> Self; + fn clamp_v(&self, mn: &Self, mx: &Self) -> Self; - pure fn min_t(&self, other: T) -> Self; - pure fn max_t(&self, other: T) -> Self; - pure fn clamp_t(&self, mn: T, mx: T) -> Self; + fn min_t(&self, other: T) -> Self; + fn max_t(&self, other: T) -> Self; + fn clamp_t(&self, mn: T, mx: T) -> Self; } pub trait MixVec: Vector { // Functions for blending numbers together - pure fn mix(&self, other: Self, value: Self) -> Self; - pure fn smooth_step(&self, edge0: Self, edge1: Self) -> Self; - pure fn step(&self, edge: Self) -> Self; + fn mix(&self, other: Self, value: Self) -> Self; + fn smooth_step(&self, edge0: Self, edge1: Self) -> Self; + fn step(&self, edge: Self) -> Self; } \ No newline at end of file diff --git a/src/vec2.rs b/src/vec2.rs index 77cb610..ed35c52 100644 --- a/src/vec2.rs +++ b/src/vec2.rs @@ -45,12 +45,12 @@ pub struct Vec2 { x: T, y: T } impl Vector for Vec2 { #[inline(always)] - static pure fn from_value(value: T) -> Vec2 { + static fn from_value(value: T) -> Vec2 { Vector2::new(value, value) } #[inline(always)] - pure fn to_ptr(&self) -> *T { + fn to_ptr(&self) -> *T { unsafe { transmute::<*Vec2, *T>( to_unsafe_ptr(self) @@ -61,14 +61,14 @@ impl Vector for Vec2 { impl Vector2 for Vec2 { #[inline(always)] - static pure fn new(x: T, y: T ) -> Vec2 { + static fn new(x: T, y: T ) -> Vec2 { Vec2 { x: x, y: y } } } impl Index for Vec2 { #[inline(always)] - pure fn index(&self, i: uint) -> T { + fn index(&self, i: uint) -> T { unsafe { do buf_as_slice(self.to_ptr(), 2) |slice| { slice[i] } } } } @@ -92,59 +92,59 @@ impl MutableVector for Vec2 { impl + Sub + Mul + Div + Neg> NumericVector for Vec2 { #[inline(always)] - static pure fn identity() -> Vec2 { + static fn identity() -> Vec2 { Vector2::new(one::(), one::()) } #[inline(always)] - static pure fn zero() -> Vec2 { + static fn zero() -> Vec2 { Vector2::new(zero::(), zero::()) } #[inline(always)] - pure fn is_zero(&self) -> bool { + fn is_zero(&self) -> bool { self[0] == zero() && self[1] == zero() } #[inline(always)] - pure fn mul_t(&self, value: T) -> Vec2 { + fn mul_t(&self, value: T) -> Vec2 { Vector2::new(self[0] * value, self[1] * value) } #[inline(always)] - pure fn div_t(&self, value: T) -> Vec2 { + fn div_t(&self, value: T) -> Vec2 { Vector2::new(self[0] / value, self[1] / value) } #[inline(always)] - pure fn add_v(&self, other: &Vec2) -> Vec2 { + fn add_v(&self, other: &Vec2) -> Vec2 { Vector2::new(self[0] + other[0], self[1] + other[1]) } #[inline(always)] - pure fn sub_v(&self, other: &Vec2) -> Vec2 { + fn sub_v(&self, other: &Vec2) -> Vec2 { Vector2::new(self[0] - other[0], self[1] - other[1]) } #[inline(always)] - pure fn mul_v(&self, other: &Vec2) -> Vec2 { + fn mul_v(&self, other: &Vec2) -> Vec2 { Vector2::new(self[0] * other[0], self[1] * other[1]) } #[inline(always)] - pure fn div_v(&self, other: &Vec2) -> Vec2 { + fn div_v(&self, other: &Vec2) -> Vec2 { Vector2::new(self[0] / other[0], self[1] / other[1]) } #[inline(always)] - pure fn dot(&self, other: &Vec2) -> T { + fn dot(&self, other: &Vec2) -> T { self[0] * other[0] + self[1] * other[1] } @@ -152,24 +152,24 @@ impl + Sub + Mul + Div + Neg> Numer impl + Sub + Mul + Div + Neg> Neg> for Vec2 { #[inline(always)] - pure fn neg(&self) -> Vec2 { + fn neg(&self) -> Vec2 { Vector2::new(-self[0], -self[1]) } } impl + Sub + Mul + Div + Neg> NumericVector2 for Vec2 { #[inline(always)] - static pure fn unit_x() -> Vec2 { + static fn unit_x() -> Vec2 { Vector2::new(one::(), zero::()) } #[inline(always)] - static pure fn unit_y() -> Vec2 { + static fn unit_y() -> Vec2 { Vector2::new(zero::(), one::()) } #[inline(always)] - pure fn perp_dot(&self, other: &Vec2) ->T { + fn perp_dot(&self, other: &Vec2) ->T { (self[0] * other[1]) - (self[1] * other[0]) } } @@ -220,49 +220,49 @@ impl + Sub + Mul + Div + Neg> Mutab impl ToHomogeneous> for Vec2 { #[inline(always)] - pure fn to_homogeneous(&self) -> Vec3 { + fn to_homogeneous(&self) -> Vec3 { Vector3::new(self.x, self.y, zero()) } } impl + Sub + Mul + Div + Neg> EuclideanVector for Vec2 { #[inline(always)] - pure fn length2(&self) -> T { + fn length2(&self) -> T { self.dot(self) } #[inline(always)] - pure fn length(&self) -> T { + fn length(&self) -> T { self.length2().sqrt() } #[inline(always)] - pure fn distance2(&self, other: &Vec2) -> T { + fn distance2(&self, other: &Vec2) -> T { other.sub_v(self).length2() } #[inline(always)] - pure fn distance(&self, other: &Vec2) -> T { + fn distance(&self, other: &Vec2) -> T { other.distance2(self).sqrt() } #[inline(always)] - pure fn angle(&self, other: &Vec2) -> T { + fn angle(&self, other: &Vec2) -> T { atan2(self.perp_dot(other), self.dot(other)) } #[inline(always)] - pure fn normalize(&self) -> Vec2 { + fn normalize(&self) -> Vec2 { self.mul_t(one::()/self.length()) } #[inline(always)] - pure fn normalize_to(&self, length: T) -> Vec2 { + fn normalize_to(&self, length: T) -> Vec2 { self.mul_t(length / self.length()) } #[inline(always)] - pure fn lerp(&self, other: &Vec2, amount: T) -> Vec2 { + fn lerp(&self, other: &Vec2, amount: T) -> Vec2 { self.add_v(&other.sub_v(self).mul_t(amount)) } } @@ -287,12 +287,12 @@ impl + Sub + Mul + Div + Neg> Mutabl impl> FuzzyEq for Vec2 { #[inline(always)] - pure fn fuzzy_eq(&self, other: &Vec2) -> bool { + fn fuzzy_eq(&self, other: &Vec2) -> bool { self.fuzzy_eq_eps(other, &Number::from(FUZZY_EPSILON)) } #[inline(always)] - pure fn fuzzy_eq_eps(&self, other: &Vec2, epsilon: &T) -> bool { + fn fuzzy_eq_eps(&self, other: &Vec2, epsilon: &T) -> bool { self[0].fuzzy_eq_eps(&other[0], epsilon) && self[1].fuzzy_eq_eps(&other[1], epsilon) } @@ -300,25 +300,25 @@ impl> FuzzyEq for Vec2 { impl OrdinalVector> for Vec2 { #[inline(always)] - pure fn less_than(&self, other: &Vec2) -> Vec2 { + fn less_than(&self, other: &Vec2) -> Vec2 { Vector2::new(self[0] < other[0], self[1] < other[1]) } #[inline(always)] - pure fn less_than_equal(&self, other: &Vec2) -> Vec2 { + fn less_than_equal(&self, other: &Vec2) -> Vec2 { Vector2::new(self[0] <= other[0], self[1] <= other[1]) } #[inline(always)] - pure fn greater_than(&self, other: &Vec2) -> Vec2 { + fn greater_than(&self, other: &Vec2) -> Vec2 { Vector2::new(self[0] > other[0], self[1] > other[1]) } #[inline(always)] - pure fn greater_than_equal(&self, other: &Vec2) -> Vec2 { + fn greater_than_equal(&self, other: &Vec2) -> Vec2 { Vector2::new(self[0] >= other[0], self[1] >= other[1]) } @@ -326,13 +326,13 @@ impl OrdinalVector> for Vec2 { impl EquableVector> for Vec2 { #[inline(always)] - pure fn equal(&self, other: &Vec2) -> Vec2 { + fn equal(&self, other: &Vec2) -> Vec2 { Vector2::new(self[0] == other[0], self[1] == other[1]) } #[inline(always)] - pure fn not_equal(&self, other: &Vec2) -> Vec2 { + fn not_equal(&self, other: &Vec2) -> Vec2 { Vector2::new(self[0] != other[0], self[1] != other[1]) } @@ -340,17 +340,17 @@ impl EquableVector> for Vec2 { impl BooleanVector for Vec2 { #[inline(always)] - pure fn any(&self) -> bool { + fn any(&self) -> bool { self[0] || self[1] } #[inline(always)] - pure fn all(&self) -> bool { + fn all(&self) -> bool { self[0] && self[1] } #[inline(always)] - pure fn not(&self) -> Vec2 { + fn not(&self) -> Vec2 { Vector2::new(!self[0], !self[1]) } } @@ -367,63 +367,63 @@ pub type uvec2 = Vec2; // a two-component unsigned integer vector // Static method wrappers for GLSL-style types impl vec2 { - #[inline(always)] static pure fn new(x: f32, y: f32) -> vec2 { Vector2::new(x, y) } - #[inline(always)] static pure fn from_value(v: f32) -> vec2 { Vector::from_value(v) } - #[inline(always)] static pure fn identity() -> vec2 { NumericVector::identity() } - #[inline(always)] static pure fn zero() -> vec2 { NumericVector::zero() } + #[inline(always)] static fn new(x: f32, y: f32) -> vec2 { Vector2::new(x, y) } + #[inline(always)] static fn from_value(v: f32) -> vec2 { Vector::from_value(v) } + #[inline(always)] static fn identity() -> vec2 { NumericVector::identity() } + #[inline(always)] static fn zero() -> vec2 { NumericVector::zero() } - #[inline(always)] static pure fn unit_x() -> vec2 { NumericVector2::unit_x() } - #[inline(always)] static pure fn unit_y() -> vec2 { NumericVector2::unit_y() } + #[inline(always)] static fn unit_x() -> vec2 { NumericVector2::unit_x() } + #[inline(always)] static fn unit_y() -> vec2 { NumericVector2::unit_y() } - #[inline(always)] static pure fn dim() -> uint { 2 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 2 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl dvec2 { - #[inline(always)] static pure fn new(x: f64, y: f64) -> dvec2 { Vector2::new(x, y) } - #[inline(always)] static pure fn from_value(v: f64) -> dvec2 { Vector::from_value(v) } - #[inline(always)] static pure fn identity() -> dvec2 { NumericVector::identity() } - #[inline(always)] static pure fn zero() -> dvec2 { NumericVector::zero() } + #[inline(always)] static fn new(x: f64, y: f64) -> dvec2 { Vector2::new(x, y) } + #[inline(always)] static fn from_value(v: f64) -> dvec2 { Vector::from_value(v) } + #[inline(always)] static fn identity() -> dvec2 { NumericVector::identity() } + #[inline(always)] static fn zero() -> dvec2 { NumericVector::zero() } - #[inline(always)] static pure fn unit_x() -> dvec2 { NumericVector2::unit_x() } - #[inline(always)] static pure fn unit_y() -> dvec2 { NumericVector2::unit_y() } + #[inline(always)] static fn unit_x() -> dvec2 { NumericVector2::unit_x() } + #[inline(always)] static fn unit_y() -> dvec2 { NumericVector2::unit_y() } - #[inline(always)] static pure fn dim() -> uint { 2 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 2 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl bvec2 { - #[inline(always)] static pure fn new(x: bool, y: bool) -> bvec2 { Vector2::new(x, y) } - #[inline(always)] static pure fn from_value(v: bool) -> bvec2 { Vector::from_value(v) } + #[inline(always)] static fn new(x: bool, y: bool) -> bvec2 { Vector2::new(x, y) } + #[inline(always)] static fn from_value(v: bool) -> bvec2 { Vector::from_value(v) } - #[inline(always)] static pure fn dim() -> uint { 2 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 2 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl ivec2 { - #[inline(always)] static pure fn new(x: i32, y: i32) -> ivec2 { Vector2::new(x, y) } - #[inline(always)] static pure fn from_value(v: i32) -> ivec2 { Vector::from_value(v) } - #[inline(always)] static pure fn identity() -> ivec2 { NumericVector::identity() } - #[inline(always)] static pure fn zero() -> ivec2 { NumericVector::zero() } + #[inline(always)] static fn new(x: i32, y: i32) -> ivec2 { Vector2::new(x, y) } + #[inline(always)] static fn from_value(v: i32) -> ivec2 { Vector::from_value(v) } + #[inline(always)] static fn identity() -> ivec2 { NumericVector::identity() } + #[inline(always)] static fn zero() -> ivec2 { NumericVector::zero() } - #[inline(always)] static pure fn unit_x() -> ivec2 { NumericVector2::unit_x() } - #[inline(always)] static pure fn unit_y() -> ivec2 { NumericVector2::unit_y() } + #[inline(always)] static fn unit_x() -> ivec2 { NumericVector2::unit_x() } + #[inline(always)] static fn unit_y() -> ivec2 { NumericVector2::unit_y() } - #[inline(always)] static pure fn dim() -> uint { 2 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 2 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl uvec2 { - #[inline(always)] static pure fn new(x: u32, y: u32) -> uvec2 { Vector2::new(x, y) } - #[inline(always)] static pure fn from_value(v: u32) -> uvec2 { Vector::from_value(v) } - #[inline(always)] static pure fn identity() -> uvec2 { NumericVector::identity() } - #[inline(always)] static pure fn zero() -> uvec2 { NumericVector::zero() } + #[inline(always)] static fn new(x: u32, y: u32) -> uvec2 { Vector2::new(x, y) } + #[inline(always)] static fn from_value(v: u32) -> uvec2 { Vector::from_value(v) } + #[inline(always)] static fn identity() -> uvec2 { NumericVector::identity() } + #[inline(always)] static fn zero() -> uvec2 { NumericVector::zero() } - #[inline(always)] static pure fn unit_x() -> uvec2 { NumericVector2::unit_x() } - #[inline(always)] static pure fn unit_y() -> uvec2 { NumericVector2::unit_y() } + #[inline(always)] static fn unit_x() -> uvec2 { NumericVector2::unit_x() } + #[inline(always)] static fn unit_y() -> uvec2 { NumericVector2::unit_y() } - #[inline(always)] static pure fn dim() -> uint { 2 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 2 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } // Type aliases named in a more 'Rustic' style diff --git a/src/vec3.rs b/src/vec3.rs index b8a0afe..f4a9a56 100644 --- a/src/vec3.rs +++ b/src/vec3.rs @@ -47,12 +47,12 @@ pub struct Vec3 { x: T, y: T, z: T } impl Vector for Vec3 { #[inline(always)] - static pure fn from_value(value: T) -> Vec3 { + static fn from_value(value: T) -> Vec3 { Vector3::new(value, value, value) } #[inline(always)] - pure fn to_ptr(&self) -> *T { + fn to_ptr(&self) -> *T { unsafe { transmute::<*Vec3, *T>( to_unsafe_ptr(self) @@ -63,14 +63,14 @@ impl Vector for Vec3 { impl Vector3 for Vec3 { #[inline(always)] - static pure fn new(x: T, y: T, z: T) -> Vec3 { + static fn new(x: T, y: T, z: T) -> Vec3 { Vec3 { x: x, y: y, z: z } } } impl Index for Vec3 { #[inline(always)] - pure fn index(&self, i: uint) -> T { + fn index(&self, i: uint) -> T { unsafe { do buf_as_slice(self.to_ptr(), 3) |slice| { slice[i] } } } } @@ -95,66 +95,66 @@ impl MutableVector for Vec3 { impl + Sub + Mul + Div + Neg> NumericVector for Vec3 { #[inline(always)] - static pure fn identity() -> Vec3 { + static fn identity() -> Vec3 { Vector3::new(one::(), one::(), one::()) } #[inline(always)] - static pure fn zero() -> Vec3 { + static fn zero() -> Vec3 { Vector3::new(zero::(), zero::(), zero::()) } #[inline(always)] - pure fn is_zero(&self) -> bool { + fn is_zero(&self) -> bool { self[0] == zero() && self[1] == zero() && self[2] == zero() } #[inline(always)] - pure fn mul_t(&self, value: T) -> Vec3 { + fn mul_t(&self, value: T) -> Vec3 { Vector3::new(self[0] * value, self[1] * value, self[2] * value) } #[inline(always)] - pure fn div_t(&self, value: T) -> Vec3 { + fn div_t(&self, value: T) -> Vec3 { Vector3::new(self[0] / value, self[1] / value, self[2] / value) } #[inline(always)] - pure fn add_v(&self, other: &Vec3) -> Vec3{ + fn add_v(&self, other: &Vec3) -> Vec3{ Vector3::new(self[0] + other[0], self[1] + other[1], self[2] + other[2]) } #[inline(always)] - pure fn sub_v(&self, other: &Vec3) -> Vec3{ + fn sub_v(&self, other: &Vec3) -> Vec3{ Vector3::new(self[0] - other[0], self[1] - other[1], self[2] - other[2]) } #[inline(always)] - pure fn mul_v(&self, other: &Vec3) -> Vec3{ + fn mul_v(&self, other: &Vec3) -> Vec3{ Vector3::new(self[0] * other[0], self[1] * other[1], self[2] * other[2]) } #[inline(always)] - pure fn div_v(&self, other: &Vec3) -> Vec3{ + fn div_v(&self, other: &Vec3) -> Vec3{ Vector3::new(self[0] / other[0], self[1] / other[1], self[2] / other[2]) } #[inline(always)] - pure fn dot(&self, other: &Vec3) -> T { + fn dot(&self, other: &Vec3) -> T { self[0] * other[0] + self[1] * other[1] + self[2] * other[2] @@ -163,29 +163,29 @@ impl + Sub + Mul + Div + Neg> Numer impl + Sub + Mul + Div + Neg> Neg> for Vec3 { #[inline(always)] - pure fn neg(&self) -> Vec3 { + fn neg(&self) -> Vec3 { Vector3::new(-self[0], -self[1], -self[2]) } } impl + Sub + Mul + Div + Neg> NumericVector3 for Vec3 { #[inline(always)] - static pure fn unit_x() -> Vec3 { + static fn unit_x() -> Vec3 { Vector3::new(one::(), zero::(), zero::()) } #[inline(always)] - static pure fn unit_y() -> Vec3 { + static fn unit_y() -> Vec3 { Vector3::new(zero::(), one::(), zero::()) } #[inline(always)] - static pure fn unit_z() -> Vec3 { + static fn unit_z() -> Vec3 { Vector3::new(zero::(), zero::(), one::()) } #[inline(always)] - pure fn cross(&self, other: &Vec3) -> Vec3 { + fn cross(&self, other: &Vec3) -> Vec3 { Vector3::new((self[1] * other[2]) - (self[2] * other[1]), (self[2] * other[0]) - (self[0] * other[2]), (self[0] * other[1]) - (self[1] * other[0])) @@ -252,49 +252,49 @@ impl + Sub + Mul + Div + Neg> Mutab impl + Sub + Mul + Div + Neg> ToHomogeneous> for Vec3 { #[inline(always)] - pure fn to_homogeneous(&self) -> Vec4 { + fn to_homogeneous(&self) -> Vec4 { Vector4::new(self.x, self.y, self.z, zero()) } } impl + Sub + Mul + Div + Neg> EuclideanVector for Vec3 { #[inline(always)] - pure fn length2(&self) -> T { + fn length2(&self) -> T { self.dot(self) } #[inline(always)] - pure fn length(&self) -> T { + fn length(&self) -> T { self.length2().sqrt() } #[inline(always)] - pure fn distance2(&self, other: &Vec3) -> T { + fn distance2(&self, other: &Vec3) -> T { other.sub_v(self).length2() } #[inline(always)] - pure fn distance(&self, other: &Vec3) -> T { + fn distance(&self, other: &Vec3) -> T { other.distance2(self).sqrt() } #[inline(always)] - pure fn angle(&self, other: &Vec3) -> T { + fn angle(&self, other: &Vec3) -> T { atan2(self.cross(other).length(), self.dot(other)) } #[inline(always)] - pure fn normalize(&self) -> Vec3 { + fn normalize(&self) -> Vec3 { self.mul_t(one::()/self.length()) } #[inline(always)] - pure fn normalize_to(&self, length: T) -> Vec3 { + fn normalize_to(&self, length: T) -> Vec3 { self.mul_t(length / self.length()) } #[inline(always)] - pure fn lerp(&self, other: &Vec3, amount: T) -> Vec3 { + fn lerp(&self, other: &Vec3, amount: T) -> Vec3 { self.add_v(&other.sub_v(self).mul_t(amount)) } } @@ -319,12 +319,12 @@ impl + Sub + Mul + Div + Neg> Mutabl impl> FuzzyEq for Vec3 { #[inline(always)] - pure fn fuzzy_eq(&self, other: &Vec3) -> bool { + fn fuzzy_eq(&self, other: &Vec3) -> bool { self.fuzzy_eq_eps(other, &Number::from(FUZZY_EPSILON)) } #[inline(always)] - pure fn fuzzy_eq_eps(&self, other: &Vec3, epsilon: &T) -> bool { + fn fuzzy_eq_eps(&self, other: &Vec3, epsilon: &T) -> bool { self[0].fuzzy_eq_eps(&other[0], epsilon) && self[1].fuzzy_eq_eps(&other[1], epsilon) && self[2].fuzzy_eq_eps(&other[2], epsilon) @@ -333,28 +333,28 @@ impl> FuzzyEq for Vec3 { impl OrdinalVector> for Vec3 { #[inline(always)] - pure fn less_than(&self, other: &Vec3) -> Vec3 { + fn less_than(&self, other: &Vec3) -> Vec3 { Vector3::new(self[0] < other[0], self[1] < other[1], self[2] < other[2]) } #[inline(always)] - pure fn less_than_equal(&self, other: &Vec3) -> Vec3 { + fn less_than_equal(&self, other: &Vec3) -> Vec3 { Vector3::new(self[0] <= other[0], self[1] <= other[1], self[2] <= other[2]) } #[inline(always)] - pure fn greater_than(&self, other: &Vec3) -> Vec3 { + fn greater_than(&self, other: &Vec3) -> Vec3 { Vector3::new(self[0] > other[0], self[1] > other[1], self[2] > other[2]) } #[inline(always)] - pure fn greater_than_equal(&self, other: &Vec3) -> Vec3 { + fn greater_than_equal(&self, other: &Vec3) -> Vec3 { Vector3::new(self[0] >= other[0], self[1] >= other[1], self[2] >= other[2]) @@ -363,14 +363,14 @@ impl OrdinalVector> for Vec3 { impl EquableVector> for Vec3 { #[inline(always)] - pure fn equal(&self, other: &Vec3) -> Vec3 { + fn equal(&self, other: &Vec3) -> Vec3 { Vector3::new(self[0] == other[0], self[1] == other[1], self[2] == other[2]) } #[inline(always)] - pure fn not_equal(&self, other: &Vec3) -> Vec3 { + fn not_equal(&self, other: &Vec3) -> Vec3 { Vector3::new(self[0] != other[0], self[1] != other[1], self[2] != other[2]) @@ -379,17 +379,17 @@ impl EquableVector> for Vec3 { impl BooleanVector for Vec3 { #[inline(always)] - pure fn any(&self) -> bool { + fn any(&self) -> bool { self[0] || self[1] || self[2] } #[inline(always)] - pure fn all(&self) -> bool { + fn all(&self) -> bool { self[0] && self[1] && self[2] } #[inline(always)] - pure fn not(&self) -> Vec3 { + fn not(&self) -> Vec3 { Vector3::new(!self[0], !self[1], !self[2]) } } @@ -406,65 +406,65 @@ pub type uvec3 = Vec3; // a three-component unsigned integer vector // Static method wrappers for GLSL-style types impl vec3 { - #[inline(always)] static pure fn new(x: f32, y: f32, z: f32) -> vec3 { Vector3::new(x, y, z) } - #[inline(always)] static pure fn from_value(v: f32) -> vec3 { Vector::from_value(v) } - #[inline(always)] static pure fn identity() -> vec3 { NumericVector::identity() } - #[inline(always)] static pure fn zero() -> vec3 { NumericVector::zero() } + #[inline(always)] static fn new(x: f32, y: f32, z: f32) -> vec3 { Vector3::new(x, y, z) } + #[inline(always)] static fn from_value(v: f32) -> vec3 { Vector::from_value(v) } + #[inline(always)] static fn identity() -> vec3 { NumericVector::identity() } + #[inline(always)] static fn zero() -> vec3 { NumericVector::zero() } - #[inline(always)] static pure fn unit_x() -> vec3 { NumericVector3::unit_x() } - #[inline(always)] static pure fn unit_y() -> vec3 { NumericVector3::unit_y() } - #[inline(always)] static pure fn unit_z() -> vec3 { NumericVector3::unit_z() } + #[inline(always)] static fn unit_x() -> vec3 { NumericVector3::unit_x() } + #[inline(always)] static fn unit_y() -> vec3 { NumericVector3::unit_y() } + #[inline(always)] static fn unit_z() -> vec3 { NumericVector3::unit_z() } - #[inline(always)] static pure fn dim() -> uint { 3 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 3 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl dvec3 { - #[inline(always)] static pure fn new(x: f64, y: f64, z: f64) -> dvec3 { Vector3::new(x, y, z) } - #[inline(always)] static pure fn from_value(v: f64) -> dvec3 { Vector::from_value(v) } - #[inline(always)] static pure fn identity() -> dvec3 { NumericVector::identity() } - #[inline(always)] static pure fn zero() -> dvec3 { NumericVector::zero() } + #[inline(always)] static fn new(x: f64, y: f64, z: f64) -> dvec3 { Vector3::new(x, y, z) } + #[inline(always)] static fn from_value(v: f64) -> dvec3 { Vector::from_value(v) } + #[inline(always)] static fn identity() -> dvec3 { NumericVector::identity() } + #[inline(always)] static fn zero() -> dvec3 { NumericVector::zero() } - #[inline(always)] static pure fn unit_x() -> dvec3 { NumericVector3::unit_x() } - #[inline(always)] static pure fn unit_y() -> dvec3 { NumericVector3::unit_y() } - #[inline(always)] static pure fn unit_z() -> dvec3 { NumericVector3::unit_z() } + #[inline(always)] static fn unit_x() -> dvec3 { NumericVector3::unit_x() } + #[inline(always)] static fn unit_y() -> dvec3 { NumericVector3::unit_y() } + #[inline(always)] static fn unit_z() -> dvec3 { NumericVector3::unit_z() } - #[inline(always)] static pure fn dim() -> uint { 3 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 3 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl bvec3 { - #[inline(always)] static pure fn new(x: bool, y: bool, z: bool) -> bvec3 { Vector3::new(x, y, z) } - #[inline(always)] static pure fn from_value(v: bool) -> bvec3 { Vector::from_value(v) } + #[inline(always)] static fn new(x: bool, y: bool, z: bool) -> bvec3 { Vector3::new(x, y, z) } + #[inline(always)] static fn from_value(v: bool) -> bvec3 { Vector::from_value(v) } - #[inline(always)] static pure fn dim() -> uint { 3 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 3 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl ivec3 { - #[inline(always)] static pure fn new(x: i32, y: i32, z: i32) -> ivec3 { Vector3::new(x, y, z) } - #[inline(always)] static pure fn from_value(v: i32) -> ivec3 { Vector::from_value(v) } - #[inline(always)] static pure fn identity() -> ivec3 { NumericVector::identity() } - #[inline(always)] static pure fn zero() -> ivec3 { NumericVector::zero() } + #[inline(always)] static fn new(x: i32, y: i32, z: i32) -> ivec3 { Vector3::new(x, y, z) } + #[inline(always)] static fn from_value(v: i32) -> ivec3 { Vector::from_value(v) } + #[inline(always)] static fn identity() -> ivec3 { NumericVector::identity() } + #[inline(always)] static fn zero() -> ivec3 { NumericVector::zero() } - #[inline(always)] static pure fn unit_x() -> ivec3 { NumericVector3::unit_x() } - #[inline(always)] static pure fn unit_y() -> ivec3 { NumericVector3::unit_y() } - #[inline(always)] static pure fn unit_z() -> ivec3 { NumericVector3::unit_z() } + #[inline(always)] static fn unit_x() -> ivec3 { NumericVector3::unit_x() } + #[inline(always)] static fn unit_y() -> ivec3 { NumericVector3::unit_y() } + #[inline(always)] static fn unit_z() -> ivec3 { NumericVector3::unit_z() } - #[inline(always)] static pure fn dim() -> uint { 3 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 3 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl uvec3 { - #[inline(always)] static pure fn new(x: u32, y: u32, z: u32) -> uvec3 { Vector3::new(x, y, z) } - #[inline(always)] static pure fn from_value(v: u32) -> uvec3 { Vector::from_value(v) } - #[inline(always)] static pure fn identity() -> uvec3 { NumericVector::identity() } - #[inline(always)] static pure fn zero() -> uvec3 { NumericVector::zero() } + #[inline(always)] static fn new(x: u32, y: u32, z: u32) -> uvec3 { Vector3::new(x, y, z) } + #[inline(always)] static fn from_value(v: u32) -> uvec3 { Vector::from_value(v) } + #[inline(always)] static fn identity() -> uvec3 { NumericVector::identity() } + #[inline(always)] static fn zero() -> uvec3 { NumericVector::zero() } - #[inline(always)] static pure fn unit_x() -> uvec3 { NumericVector3::unit_x() } - #[inline(always)] static pure fn unit_y() -> uvec3 { NumericVector3::unit_y() } - #[inline(always)] static pure fn unit_z() -> uvec3 { NumericVector3::unit_z() } + #[inline(always)] static fn unit_x() -> uvec3 { NumericVector3::unit_x() } + #[inline(always)] static fn unit_y() -> uvec3 { NumericVector3::unit_y() } + #[inline(always)] static fn unit_z() -> uvec3 { NumericVector3::unit_z() } - #[inline(always)] static pure fn dim() -> uint { 3 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 3 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } diff --git a/src/vec4.rs b/src/vec4.rs index 0459996..ac4a7ad 100644 --- a/src/vec4.rs +++ b/src/vec4.rs @@ -45,12 +45,12 @@ pub struct Vec4 { x: T, y: T, z: T, w: T } impl Vector for Vec4 { #[inline(always)] - static pure fn from_value(value: T) -> Vec4 { + static fn from_value(value: T) -> Vec4 { Vector4::new(value, value, value, value) } #[inline(always)] - pure fn to_ptr(&self) -> *T { + fn to_ptr(&self) -> *T { unsafe { transmute::<*Vec4, *T>( to_unsafe_ptr(self) @@ -61,14 +61,14 @@ impl Vector for Vec4 { impl Vector4 for Vec4 { #[inline(always)] - static pure fn new(x: T, y: T, z: T, w: T) -> Vec4 { + static fn new(x: T, y: T, z: T, w: T) -> Vec4 { Vec4 { x: x, y: y, z: z, w: w } } } impl Index for Vec4 { #[inline(always)] - pure fn index(&self, i: uint) -> T { + fn index(&self, i: uint) -> T { unsafe { do buf_as_slice(self.to_ptr(), 4) |slice| { slice[i] } } } } @@ -94,17 +94,17 @@ impl MutableVector for Vec4 { impl + Sub + Mul + Div + Neg> NumericVector for Vec4 { #[inline(always)] - static pure fn identity() -> Vec4 { + static fn identity() -> Vec4 { Vector4::new(one::(), one::(), one::(), one::()) } #[inline(always)] - static pure fn zero() -> Vec4 { + static fn zero() -> Vec4 { Vector4::new(zero::(), zero::(), zero::(), zero::()) } #[inline(always)] - pure fn is_zero(&self) -> bool { + fn is_zero(&self) -> bool { self[0] == zero() && self[1] == zero() && self[2] == zero() && @@ -112,7 +112,7 @@ impl + Sub + Mul + Div + Neg> Numer } #[inline(always)] - pure fn mul_t(&self, value: T) -> Vec4 { + fn mul_t(&self, value: T) -> Vec4 { Vector4::new(self[0] * value, self[1] * value, self[2] * value, @@ -120,7 +120,7 @@ impl + Sub + Mul + Div + Neg> Numer } #[inline(always)] - pure fn div_t(&self, value: T) -> Vec4 { + fn div_t(&self, value: T) -> Vec4 { Vector4::new(self[0] / value, self[1] / value, self[2] / value, @@ -128,7 +128,7 @@ impl + Sub + Mul + Div + Neg> Numer } #[inline(always)] - pure fn add_v(&self, other: &Vec4) -> Vec4 { + fn add_v(&self, other: &Vec4) -> Vec4 { Vector4::new(self[0] + other[0], self[1] + other[1], self[2] + other[2], @@ -136,7 +136,7 @@ impl + Sub + Mul + Div + Neg> Numer } #[inline(always)] - pure fn sub_v(&self, other: &Vec4) -> Vec4 { + fn sub_v(&self, other: &Vec4) -> Vec4 { Vector4::new(self[0] - other[0], self[1] - other[1], self[2] - other[2], @@ -144,7 +144,7 @@ impl + Sub + Mul + Div + Neg> Numer } #[inline(always)] - pure fn mul_v(&self, other: &Vec4) -> Vec4 { + fn mul_v(&self, other: &Vec4) -> Vec4 { Vector4::new(self[0] * other[0], self[1] * other[1], self[2] * other[2], @@ -152,7 +152,7 @@ impl + Sub + Mul + Div + Neg> Numer } #[inline(always)] - pure fn div_v(&self, other: &Vec4) -> Vec4 { + fn div_v(&self, other: &Vec4) -> Vec4 { Vector4::new(self[0] / other[0], self[1] / other[1], self[2] / other[2], @@ -160,7 +160,7 @@ impl + Sub + Mul + Div + Neg> Numer } #[inline(always)] - pure fn dot(&self, other: &Vec4) -> T { + fn dot(&self, other: &Vec4) -> T { self[0] * other[0] + self[1] * other[1] + self[2] * other[2] + @@ -170,29 +170,29 @@ impl + Sub + Mul + Div + Neg> Numer impl + Sub + Mul + Div + Neg> Neg> for Vec4 { #[inline(always)] - pure fn neg(&self) -> Vec4 { + fn neg(&self) -> Vec4 { Vector4::new(-self[0], -self[1], -self[2], -self[3]) } } impl NumericVector4 for Vec4 { #[inline(always)] - static pure fn unit_x() -> Vec4 { + static fn unit_x() -> Vec4 { Vector4::new(one::(), zero::(), zero::(), zero::()) } #[inline(always)] - static pure fn unit_y() -> Vec4 { + static fn unit_y() -> Vec4 { Vector4::new(zero::(), one::(), zero::(), zero::()) } #[inline(always)] - static pure fn unit_z() -> Vec4 { + static fn unit_z() -> Vec4 { Vector4::new(zero::(), zero::(), one::(), zero::()) } #[inline(always)] - static pure fn unit_w() -> Vec4 { + static fn unit_w() -> Vec4 { Vector4::new(zero::(), zero::(), zero::(), one::()) } } @@ -257,42 +257,42 @@ impl + Sub + Mul + Div + Neg> Mutab impl + Sub + Mul + Div + Neg> EuclideanVector for Vec4 { #[inline(always)] - pure fn length2(&self) -> T { + fn length2(&self) -> T { self.dot(self) } #[inline(always)] - pure fn length(&self) -> T { + fn length(&self) -> T { self.length2().sqrt() } #[inline(always)] - pure fn distance2(&self, other: &Vec4) -> T { + fn distance2(&self, other: &Vec4) -> T { other.sub_v(self).length2() } #[inline(always)] - pure fn distance(&self, other: &Vec4) -> T { + fn distance(&self, other: &Vec4) -> T { other.distance2(self).sqrt() } #[inline(always)] - pure fn angle(&self, other: &Vec4) -> T { + fn angle(&self, other: &Vec4) -> T { acos(self.dot(other) / (self.length() * other.length())) } #[inline(always)] - pure fn normalize(&self) -> Vec4 { + fn normalize(&self) -> Vec4 { self.mul_t(one::()/self.length()) } #[inline(always)] - pure fn normalize_to(&self, length: T) -> Vec4 { + fn normalize_to(&self, length: T) -> Vec4 { self.mul_t(length / self.length()) } #[inline(always)] - pure fn lerp(&self, other: &Vec4, amount: T) -> Vec4 { + fn lerp(&self, other: &Vec4, amount: T) -> Vec4 { self.add_v(&other.sub_v(self).mul_t(amount)) } } @@ -317,12 +317,12 @@ impl + Sub + Mul + Div + Neg> Mutabl impl> FuzzyEq for Vec4 { #[inline(always)] - pure fn fuzzy_eq(&self, other: &Vec4) -> bool { + fn fuzzy_eq(&self, other: &Vec4) -> bool { self.fuzzy_eq_eps(other, &Number::from(FUZZY_EPSILON)) } #[inline(always)] - pure fn fuzzy_eq_eps(&self, other: &Vec4, epsilon: &T) -> bool { + fn fuzzy_eq_eps(&self, other: &Vec4, epsilon: &T) -> bool { self[0].fuzzy_eq_eps(&other[0], epsilon) && self[1].fuzzy_eq_eps(&other[1], epsilon) && self[2].fuzzy_eq_eps(&other[2], epsilon) && @@ -332,7 +332,7 @@ impl> FuzzyEq for Vec4 { impl OrdinalVector> for Vec4 { #[inline(always)] - pure fn less_than(&self, other: &Vec4) -> Vec4 { + fn less_than(&self, other: &Vec4) -> Vec4 { Vector4::new(self[0] < other[0], self[1] < other[1], self[2] < other[2], @@ -340,7 +340,7 @@ impl OrdinalVector> for Vec4 { } #[inline(always)] - pure fn less_than_equal(&self, other: &Vec4) -> Vec4 { + fn less_than_equal(&self, other: &Vec4) -> Vec4 { Vector4::new(self[0] <= other[0], self[1] <= other[1], self[2] <= other[2], @@ -348,7 +348,7 @@ impl OrdinalVector> for Vec4 { } #[inline(always)] - pure fn greater_than(&self, other: &Vec4) -> Vec4 { + fn greater_than(&self, other: &Vec4) -> Vec4 { Vector4::new(self[0] > other[0], self[1] > other[1], self[2] > other[2], @@ -356,7 +356,7 @@ impl OrdinalVector> for Vec4 { } #[inline(always)] - pure fn greater_than_equal(&self, other: &Vec4) -> Vec4 { + fn greater_than_equal(&self, other: &Vec4) -> Vec4 { Vector4::new(self[0] >= other[0], self[1] >= other[1], self[2] >= other[2], @@ -366,7 +366,7 @@ impl OrdinalVector> for Vec4 { impl EquableVector> for Vec4 { #[inline(always)] - pure fn equal(&self, other: &Vec4) -> Vec4 { + fn equal(&self, other: &Vec4) -> Vec4 { Vector4::new(self[0] == other[0], self[1] == other[1], self[2] == other[2], @@ -374,7 +374,7 @@ impl EquableVector> for Vec4 { } #[inline(always)] - pure fn not_equal(&self, other: &Vec4) -> Vec4 { + fn not_equal(&self, other: &Vec4) -> Vec4 { Vector4::new(self[0] != other[0], self[1] != other[1], self[2] != other[2], @@ -384,17 +384,17 @@ impl EquableVector> for Vec4 { impl BooleanVector for Vec4 { #[inline(always)] - pure fn any(&self) -> bool { + fn any(&self) -> bool { self[0] || self[1] || self[2] || self[3] } #[inline(always)] - pure fn all(&self) -> bool { + fn all(&self) -> bool { self[0] && self[1] && self[2] && self[3] } #[inline(always)] - pure fn not(&self) -> Vec4 { + fn not(&self) -> Vec4 { Vector4::new(!self[0], !self[1], !self[2], !self[3]) } } @@ -411,70 +411,70 @@ pub type uvec4 = Vec4; // a four-component unsigned integer vector // Static method wrappers for GLSL-style types impl vec4 { - #[inline(always)] static pure fn new(x: f32, y: f32, z: f32, w: f32) -> vec4 { Vector4::new(x, y, z, w) } - #[inline(always)] static pure fn from_value(v: f32) -> vec4 { Vector::from_value(v) } - #[inline(always)] static pure fn identity() -> vec4 { NumericVector::identity() } - #[inline(always)] static pure fn zero() -> vec4 { NumericVector::zero() } + #[inline(always)] static fn new(x: f32, y: f32, z: f32, w: f32) -> vec4 { Vector4::new(x, y, z, w) } + #[inline(always)] static fn from_value(v: f32) -> vec4 { Vector::from_value(v) } + #[inline(always)] static fn identity() -> vec4 { NumericVector::identity() } + #[inline(always)] static fn zero() -> vec4 { NumericVector::zero() } - #[inline(always)] static pure fn unit_x() -> vec4 { NumericVector4::unit_x() } - #[inline(always)] static pure fn unit_y() -> vec4 { NumericVector4::unit_y() } - #[inline(always)] static pure fn unit_z() -> vec4 { NumericVector4::unit_z() } - #[inline(always)] static pure fn unit_w() -> vec4 { NumericVector4::unit_w() } + #[inline(always)] static fn unit_x() -> vec4 { NumericVector4::unit_x() } + #[inline(always)] static fn unit_y() -> vec4 { NumericVector4::unit_y() } + #[inline(always)] static fn unit_z() -> vec4 { NumericVector4::unit_z() } + #[inline(always)] static fn unit_w() -> vec4 { NumericVector4::unit_w() } - #[inline(always)] static pure fn dim() -> uint { 4 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 4 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl dvec4 { - #[inline(always)] static pure fn new(x: f64, y: f64, z: f64, w: f64) -> dvec4 { Vector4::new(x, y, z, w) } - #[inline(always)] static pure fn from_value(v: f64) -> dvec4 { Vector::from_value(v) } - #[inline(always)] static pure fn identity() -> dvec4 { NumericVector::identity() } - #[inline(always)] static pure fn zero() -> dvec4 { NumericVector::zero() } + #[inline(always)] static fn new(x: f64, y: f64, z: f64, w: f64) -> dvec4 { Vector4::new(x, y, z, w) } + #[inline(always)] static fn from_value(v: f64) -> dvec4 { Vector::from_value(v) } + #[inline(always)] static fn identity() -> dvec4 { NumericVector::identity() } + #[inline(always)] static fn zero() -> dvec4 { NumericVector::zero() } - #[inline(always)] static pure fn unit_x() -> dvec4 { NumericVector4::unit_x() } - #[inline(always)] static pure fn unit_y() -> dvec4 { NumericVector4::unit_y() } - #[inline(always)] static pure fn unit_z() -> dvec4 { NumericVector4::unit_z() } - #[inline(always)] static pure fn unit_w() -> dvec4 { NumericVector4::unit_w() } + #[inline(always)] static fn unit_x() -> dvec4 { NumericVector4::unit_x() } + #[inline(always)] static fn unit_y() -> dvec4 { NumericVector4::unit_y() } + #[inline(always)] static fn unit_z() -> dvec4 { NumericVector4::unit_z() } + #[inline(always)] static fn unit_w() -> dvec4 { NumericVector4::unit_w() } - #[inline(always)] static pure fn dim() -> uint { 4 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 4 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl bvec4 { - #[inline(always)] static pure fn new(x: bool, y: bool, z: bool, w: bool) -> bvec4 { Vector4::new(x, y, z, w) } - #[inline(always)] static pure fn from_value(v: bool) -> bvec4 { Vector::from_value(v) } + #[inline(always)] static fn new(x: bool, y: bool, z: bool, w: bool) -> bvec4 { Vector4::new(x, y, z, w) } + #[inline(always)] static fn from_value(v: bool) -> bvec4 { Vector::from_value(v) } - #[inline(always)] static pure fn dim() -> uint { 4 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 4 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl ivec4 { - #[inline(always)] static pure fn new(x: i32, y: i32, z: i32, w: i32) -> ivec4 { Vector4::new(x, y, z, w) } - #[inline(always)] static pure fn from_value(v: i32) -> ivec4 { Vector::from_value(v) } - #[inline(always)] static pure fn identity() -> ivec4 { NumericVector::identity() } - #[inline(always)] static pure fn zero() -> ivec4 { NumericVector::zero() } + #[inline(always)] static fn new(x: i32, y: i32, z: i32, w: i32) -> ivec4 { Vector4::new(x, y, z, w) } + #[inline(always)] static fn from_value(v: i32) -> ivec4 { Vector::from_value(v) } + #[inline(always)] static fn identity() -> ivec4 { NumericVector::identity() } + #[inline(always)] static fn zero() -> ivec4 { NumericVector::zero() } - #[inline(always)] static pure fn unit_x() -> ivec4 { NumericVector4::unit_x() } - #[inline(always)] static pure fn unit_y() -> ivec4 { NumericVector4::unit_y() } - #[inline(always)] static pure fn unit_z() -> ivec4 { NumericVector4::unit_z() } - #[inline(always)] static pure fn unit_w() -> ivec4 { NumericVector4::unit_w() } + #[inline(always)] static fn unit_x() -> ivec4 { NumericVector4::unit_x() } + #[inline(always)] static fn unit_y() -> ivec4 { NumericVector4::unit_y() } + #[inline(always)] static fn unit_z() -> ivec4 { NumericVector4::unit_z() } + #[inline(always)] static fn unit_w() -> ivec4 { NumericVector4::unit_w() } - #[inline(always)] static pure fn dim() -> uint { 4 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 4 } + #[inline(always)] static fn size_of() -> uint { size_of::() } } impl uvec4 { - #[inline(always)] static pure fn new(x: u32, y: u32, z: u32, w: u32) -> uvec4 { Vector4::new(x, y, z, w) } - #[inline(always)] static pure fn from_value(v: u32) -> uvec4 { Vector::from_value(v) } - #[inline(always)] static pure fn identity() -> uvec4 { NumericVector::identity() } - #[inline(always)] static pure fn zero() -> uvec4 { NumericVector::zero() } + #[inline(always)] static fn new(x: u32, y: u32, z: u32, w: u32) -> uvec4 { Vector4::new(x, y, z, w) } + #[inline(always)] static fn from_value(v: u32) -> uvec4 { Vector::from_value(v) } + #[inline(always)] static fn identity() -> uvec4 { NumericVector::identity() } + #[inline(always)] static fn zero() -> uvec4 { NumericVector::zero() } - #[inline(always)] static pure fn unit_x() -> uvec4 { NumericVector4::unit_x() } - #[inline(always)] static pure fn unit_y() -> uvec4 { NumericVector4::unit_y() } - #[inline(always)] static pure fn unit_z() -> uvec4 { NumericVector4::unit_z() } - #[inline(always)] static pure fn unit_w() -> uvec4 { NumericVector4::unit_w() } + #[inline(always)] static fn unit_x() -> uvec4 { NumericVector4::unit_x() } + #[inline(always)] static fn unit_y() -> uvec4 { NumericVector4::unit_y() } + #[inline(always)] static fn unit_z() -> uvec4 { NumericVector4::unit_z() } + #[inline(always)] static fn unit_w() -> uvec4 { NumericVector4::unit_w() } - #[inline(always)] static pure fn dim() -> uint { 4 } - #[inline(always)] static pure fn size_of() -> uint { size_of::() } + #[inline(always)] static fn dim() -> uint { 4 } + #[inline(always)] static fn size_of() -> uint { size_of::() } }