Use _s suffix instead of _t for methods that take scalar values

This is what rust-geom uses, and it seems to make more sense. I originally used _t because it referred to the base generic type, but I think _s makes more sense.
This commit is contained in:
Brendan Zabarauskas 2013-07-19 11:08:55 +10:00
parent 58c1fe7e1c
commit a5c00bfe97
5 changed files with 166 additions and 166 deletions

View file

@ -36,7 +36,7 @@ impl<T:Clone + Float> AABB2<T> {
pub fn from_bounds(mn: Point2<T>, mx: Point2<T>) -> AABB2<T> { pub fn from_bounds(mn: Point2<T>, mx: Point2<T>) -> AABB2<T> {
AABB2 { AABB2 {
center: Point2::from_vec2( center: Point2::from_vec2(
mn.as_vec2().add_v(mx.as_vec2()).div_t(two!(T)) mn.as_vec2().add_v(mx.as_vec2()).div_s(two!(T))
), ),
size: mx - mn, size: mx - mn,
} }
@ -62,7 +62,7 @@ impl<T:Clone + Float> AABB3<T> {
pub fn from_bounds(mn: Point3<T>, mx: Point3<T>) -> AABB3<T> { pub fn from_bounds(mn: Point3<T>, mx: Point3<T>) -> AABB3<T> {
AABB3 { AABB3 {
center: Point3::from_vec3( center: Point3::from_vec3(
mn.as_vec3().add_v(mx.as_vec3()).div_t(two!(T)) mn.as_vec3().add_v(mx.as_vec3()).div_s(two!(T))
), ),
size: mx - mn, size: mx - mn,
} }

View file

@ -34,12 +34,12 @@ pub trait Mat<T,Vec,Slice>: Dimensioned<Vec,Slice>
} }
pub trait NumMat<T,Vec,Slice>: Mat<T,Vec,Slice> + Neg<Self> { pub trait NumMat<T,Vec,Slice>: Mat<T,Vec,Slice> + Neg<Self> {
pub fn mul_t(&self, value: T) -> Self; pub fn mul_s(&self, value: T) -> Self;
pub fn mul_v(&self, vec: &Vec) -> Vec; pub fn mul_v(&self, vec: &Vec) -> Vec;
pub fn add_m(&self, other: &Self) -> Self; pub fn add_m(&self, other: &Self) -> Self;
pub fn sub_m(&self, other: &Self) -> Self; pub fn sub_m(&self, other: &Self) -> Self;
pub fn mul_m(&self, other: &Self) -> Self; pub fn mul_m(&self, other: &Self) -> Self;
pub fn mul_self_t(&mut self, value: T); pub fn mul_self_s(&mut self, value: T);
pub fn add_self_m(&mut self, other: &Self); pub fn add_self_m(&mut self, other: &Self);
pub fn sub_self_m(&mut self, other: &Self); pub fn sub_self_m(&mut self, other: &Self);
pub fn dot(&self, other: &Self) -> T; pub fn dot(&self, other: &Self) -> T;
@ -202,9 +202,9 @@ impl<T:Clone + Num> Mat2<T> {
impl<T:Clone + Num> NumMat<T,Vec2<T>,[Vec2<T>,..2]> for Mat2<T> { impl<T:Clone + Num> NumMat<T,Vec2<T>,[Vec2<T>,..2]> for Mat2<T> {
#[inline] #[inline]
pub fn mul_t(&self, value: T) -> Mat2<T> { pub fn mul_s(&self, value: T) -> Mat2<T> {
Mat2::from_cols(self.col(0).mul_t(value.clone()), Mat2::from_cols(self.col(0).mul_s(value.clone()),
self.col(1).mul_t(value.clone())) self.col(1).mul_s(value.clone()))
} }
#[inline] #[inline]
@ -235,9 +235,9 @@ impl<T:Clone + Num> NumMat<T,Vec2<T>,[Vec2<T>,..2]> for Mat2<T> {
} }
#[inline] #[inline]
pub fn mul_self_t(&mut self, value: T) { pub fn mul_self_s(&mut self, value: T) {
self.col_mut(0).mul_self_t(value.clone()); self.col_mut(0).mul_self_s(value.clone());
self.col_mut(1).mul_self_t(value.clone()); self.col_mut(1).mul_self_s(value.clone());
} }
#[inline] #[inline]
@ -408,13 +408,13 @@ mod mat2_tests{
} }
#[test] #[test]
fn test_mul_t() { fn test_mul_s() {
assert_eq!(A.mul_t(F), assert_eq!(A.mul_s(F),
Mat2::new::<float>(0.5, 1.5, Mat2::new::<float>(0.5, 1.5,
1.0, 2.0)); 1.0, 2.0));
let mut mut_a = A; let mut mut_a = A;
mut_a.mul_self_t(F); mut_a.mul_self_s(F);
assert_eq!(mut_a, A.mul_t(F)); assert_eq!(mut_a, A.mul_s(F));
} }
#[test] #[test]
@ -685,10 +685,10 @@ impl<T:Clone + Num> Mat3<T> {
impl<T:Clone + Num> NumMat<T,Vec3<T>,[Vec3<T>,..3]> for Mat3<T> { impl<T:Clone + Num> NumMat<T,Vec3<T>,[Vec3<T>,..3]> for Mat3<T> {
#[inline] #[inline]
pub fn mul_t(&self, value: T) -> Mat3<T> { pub fn mul_s(&self, value: T) -> Mat3<T> {
Mat3::from_cols(self.col(0).mul_t(value.clone()), Mat3::from_cols(self.col(0).mul_s(value.clone()),
self.col(1).mul_t(value.clone()), self.col(1).mul_s(value.clone()),
self.col(2).mul_t(value.clone())) self.col(2).mul_s(value.clone()))
} }
#[inline] #[inline]
@ -728,10 +728,10 @@ impl<T:Clone + Num> NumMat<T,Vec3<T>,[Vec3<T>,..3]> for Mat3<T> {
} }
#[inline] #[inline]
pub fn mul_self_t(&mut self, value: T) { pub fn mul_self_s(&mut self, value: T) {
self.col_mut(0).mul_self_t(value.clone()); self.col_mut(0).mul_self_s(value.clone());
self.col_mut(1).mul_self_t(value.clone()); self.col_mut(1).mul_self_s(value.clone());
self.col_mut(2).mul_self_t(value.clone()); self.col_mut(2).mul_self_s(value.clone());
} }
#[inline] #[inline]
@ -851,9 +851,9 @@ impl<T:Clone + Float> FloatMat<T,Vec4<T>,[Vec4<T>,..4]> for Mat3<T> {
if d.approx_eq(&zero!(T)) { if d.approx_eq(&zero!(T)) {
None None
} else { } else {
Some(Mat3::from_cols(self.col(1).cross(self.col(2)).div_t(d.clone()), Some(Mat3::from_cols(self.col(1).cross(self.col(2)).div_s(d.clone()),
self.col(2).cross(self.col(0)).div_t(d.clone()), self.col(2).cross(self.col(0)).div_s(d.clone()),
self.col(0).cross(self.col(1)).div_t(d.clone())).transpose()) self.col(0).cross(self.col(1)).div_s(d.clone())).transpose())
} }
} }
@ -992,14 +992,14 @@ mod mat3_tests{
} }
#[test] #[test]
fn test_mul_t() { fn test_mul_s() {
assert_eq!(A.mul_t(F), assert_eq!(A.mul_s(F),
Mat3::new::<float>(0.5, 2.0, 3.5, Mat3::new::<float>(0.5, 2.0, 3.5,
1.0, 2.5, 4.0, 1.0, 2.5, 4.0,
1.5, 3.0, 4.5)); 1.5, 3.0, 4.5));
let mut mut_a = A; let mut mut_a = A;
mut_a.mul_self_t(F); mut_a.mul_self_s(F);
assert_eq!(mut_a, A.mul_t(F)); assert_eq!(mut_a, A.mul_s(F));
} }
#[test] #[test]
@ -1275,11 +1275,11 @@ impl<T:Clone + Num> Mat4<T> {
impl<T:Clone + Num> NumMat<T,Vec4<T>,[Vec4<T>,..4]> for Mat4<T> { impl<T:Clone + Num> NumMat<T,Vec4<T>,[Vec4<T>,..4]> for Mat4<T> {
#[inline] #[inline]
pub fn mul_t(&self, value: T) -> Mat4<T> { pub fn mul_s(&self, value: T) -> Mat4<T> {
Mat4::from_cols(self.col(0).mul_t(value.clone()), Mat4::from_cols(self.col(0).mul_s(value.clone()),
self.col(1).mul_t(value.clone()), self.col(1).mul_s(value.clone()),
self.col(2).mul_t(value.clone()), self.col(2).mul_s(value.clone()),
self.col(3).mul_t(value.clone())) self.col(3).mul_s(value.clone()))
} }
#[inline] #[inline]
@ -1330,11 +1330,11 @@ impl<T:Clone + Num> NumMat<T,Vec4<T>,[Vec4<T>,..4]> for Mat4<T> {
} }
#[inline] #[inline]
pub fn mul_self_t(&mut self, value: T) { pub fn mul_self_s(&mut self, value: T) {
self.col_mut(0).mul_self_t(value.clone()); self.col_mut(0).mul_self_s(value.clone());
self.col_mut(1).mul_self_t(value.clone()); self.col_mut(1).mul_self_s(value.clone());
self.col_mut(2).mul_self_t(value.clone()); self.col_mut(2).mul_self_s(value.clone());
self.col_mut(3).mul_self_t(value.clone()); self.col_mut(3).mul_self_s(value.clone());
} }
#[inline] #[inline]
@ -1431,15 +1431,15 @@ impl<T:Clone + Float> FloatMat<T,Vec4<T>,[Vec4<T>,..4]> for Mat4<T> {
// Scale col j to have a unit diagonal // Scale col j to have a unit diagonal
let ajj = A.elem(j, j).clone(); let ajj = A.elem(j, j).clone();
I.col_mut(j).div_self_t(ajj.clone()); I.col_mut(j).div_self_s(ajj.clone());
A.col_mut(j).div_self_t(ajj.clone()); A.col_mut(j).div_self_s(ajj.clone());
// Eliminate off-diagonal elems in col j of A, // Eliminate off-diagonal elems in col j of A,
// doing identical ops to I // doing identical ops to I
for uint::range(0, 4) |i| { for uint::range(0, 4) |i| {
if i != j { if i != j {
let ij_mul_aij = I.col(j).mul_t(A.elem(i, j).clone()); let ij_mul_aij = I.col(j).mul_s(A.elem(i, j).clone());
let aj_mul_aij = A.col(j).mul_t(A.elem(i, j).clone()); let aj_mul_aij = A.col(j).mul_s(A.elem(i, j).clone());
I.col_mut(i).sub_self_v(&ij_mul_aij); I.col_mut(i).sub_self_v(&ij_mul_aij);
A.col_mut(i).sub_self_v(&aj_mul_aij); A.col_mut(i).sub_self_v(&aj_mul_aij);
} }
@ -1605,15 +1605,15 @@ mod mat4_tests {
} }
#[test] #[test]
fn test_mul_t() { fn test_mul_s() {
assert_eq!(A.mul_t(F), assert_eq!(A.mul_s(F),
Mat4::new::<float>(0.5, 2.5, 4.5, 6.5, Mat4::new::<float>(0.5, 2.5, 4.5, 6.5,
1.0, 3.0, 5.0, 7.0, 1.0, 3.0, 5.0, 7.0,
1.5, 3.5, 5.5, 7.5, 1.5, 3.5, 5.5, 7.5,
2.0, 4.0, 6.0, 8.0)); 2.0, 4.0, 6.0, 8.0));
let mut mut_a = A; let mut mut_a = A;
mut_a.mul_self_t(F); mut_a.mul_self_s(F);
assert_eq!(mut_a, A.mul_t(F)); assert_eq!(mut_a, A.mul_s(F));
} }
#[test] #[test]
@ -1680,7 +1680,7 @@ mod mat4_tests {
Mat4::new::<float>( 5.0, -4.0, 1.0, 0.0, Mat4::new::<float>( 5.0, -4.0, 1.0, 0.0,
-4.0, 8.0, -4.0, 0.0, -4.0, 8.0, -4.0, 0.0,
4.0, -8.0, 4.0, 8.0, 4.0, -8.0, 4.0, 8.0,
-3.0, 4.0, 1.0, -8.0).mul_t(0.125)); -3.0, 4.0, 1.0, -8.0).mul_s(0.125));
let mut mut_c = C; let mut mut_c = C;
mut_c.invert_self(); mut_c.invert_self();
assert_eq!(mut_c, C.inverse().unwrap()); assert_eq!(mut_c, C.inverse().unwrap());

View file

@ -84,21 +84,21 @@ impl<T:Clone + Float> Quat<T> {
/// The result of multiplying the quaternion a scalar /// The result of multiplying the quaternion a scalar
#[inline] #[inline]
pub fn mul_t(&self, value: T) -> Quat<T> { pub fn mul_s(&self, value: T) -> Quat<T> {
Quat::from_sv(self.s * value, self.v.mul_t(value)) Quat::from_sv(self.s * value, self.v.mul_s(value))
} }
/// The result of dividing the quaternion a scalar /// The result of dividing the quaternion a scalar
#[inline] #[inline]
pub fn div_t(&self, value: T) -> Quat<T> { pub fn div_s(&self, value: T) -> Quat<T> {
Quat::from_sv(self.s / value, self.v.div_t(value)) Quat::from_sv(self.s / value, self.v.div_s(value))
} }
/// The result of multiplying the quaternion by a vector /// The result of multiplying the quaternion by a vector
#[inline] #[inline]
pub fn mul_v(&self, vec: &Vec3<T>) -> Vec3<T> { pub fn mul_v(&self, vec: &Vec3<T>) -> Vec3<T> {
let tmp = self.v.cross(vec).add_v(&vec.mul_t(self.s.clone())); let tmp = self.v.cross(vec).add_v(&vec.mul_s(self.s.clone()));
self.v.cross(&tmp).mul_t(two!(T)).add_v(vec) self.v.cross(&tmp).mul_s(two!(T)).add_v(vec)
} }
/// The sum of this quaternion and `other` /// The sum of this quaternion and `other`
@ -142,7 +142,7 @@ impl<T:Clone + Float> Quat<T> {
/// The multiplicative inverse of the quaternion /// The multiplicative inverse of the quaternion
#[inline] #[inline]
pub fn inverse(&self) -> Quat<T> { pub fn inverse(&self) -> Quat<T> {
self.conjugate().div_t(self.magnitude2()) self.conjugate().div_s(self.magnitude2())
} }
/// The squared magnitude of the quaternion. This is useful for /// The squared magnitude of the quaternion. This is useful for
@ -168,7 +168,7 @@ impl<T:Clone + Float> Quat<T> {
/// The normalized quaternion /// The normalized quaternion
#[inline] #[inline]
pub fn normalize(&self) -> Quat<T> { pub fn normalize(&self) -> Quat<T> {
self.mul_t(one!(T) / self.magnitude()) self.mul_s(one!(T) / self.magnitude())
} }
/// Normalised linear interpolation /// Normalised linear interpolation
@ -177,7 +177,7 @@ impl<T:Clone + Float> Quat<T> {
/// ///
/// The intoperlated quaternion /// The intoperlated quaternion
pub fn nlerp(&self, other: &Quat<T>, amount: T) -> Quat<T> { pub fn nlerp(&self, other: &Quat<T>, amount: T) -> Quat<T> {
self.mul_t(one!(T) - amount).add_q(&other.mul_t(amount)).normalize() self.mul_s(one!(T) - amount).add_q(&other.mul_s(amount)).normalize()
} }
} }
@ -261,11 +261,11 @@ impl<T:Clone + Float> Quat<T> {
let theta_0 = robust_dot.acos(); // the angle between the quaternions let theta_0 = robust_dot.acos(); // the angle between the quaternions
let theta = theta_0 * amount; // the fraction of theta specified by `amount` let theta = theta_0 * amount; // the fraction of theta specified by `amount`
let q = other.sub_q(&self.mul_t(robust_dot)) let q = other.sub_q(&self.mul_s(robust_dot))
.normalize(); .normalize();
self.mul_t(theta.cos()) self.mul_s(theta.cos())
.add_q(&q.mul_t(theta.sin())) .add_q(&q.mul_s(theta.sin()))
} }
} }
} }

View file

@ -23,11 +23,11 @@ pub trait Vec<T,Slice>: Dimensioned<T,Slice>
/// Vectors with numeric components /// Vectors with numeric components
pub trait NumVec<T,Slice>: Neg<T> { pub trait NumVec<T,Slice>: Neg<T> {
pub fn add_t(&self, value: T) -> Self; pub fn add_s(&self, value: T) -> Self;
pub fn sub_t(&self, value: T) -> Self; pub fn sub_s(&self, value: T) -> Self;
pub fn mul_t(&self, value: T) -> Self; pub fn mul_s(&self, value: T) -> Self;
pub fn div_t(&self, value: T) -> Self; pub fn div_s(&self, value: T) -> Self;
pub fn rem_t(&self, value: T) -> Self; pub fn rem_s(&self, value: T) -> Self;
pub fn add_v(&self, other: &Self) -> Self; pub fn add_v(&self, other: &Self) -> Self;
pub fn sub_v(&self, other: &Self) -> Self; pub fn sub_v(&self, other: &Self) -> Self;
@ -36,11 +36,11 @@ pub trait NumVec<T,Slice>: Neg<T> {
pub fn rem_v(&self, other: &Self) -> Self; pub fn rem_v(&self, other: &Self) -> Self;
pub fn neg_self(&mut self); pub fn neg_self(&mut self);
pub fn add_self_t(&mut self, value: T); pub fn add_self_s(&mut self, value: T);
pub fn sub_self_t(&mut self, value: T); pub fn sub_self_s(&mut self, value: T);
pub fn mul_self_t(&mut self, value: T); pub fn mul_self_s(&mut self, value: T);
pub fn div_self_t(&mut self, value: T); pub fn div_self_s(&mut self, value: T);
pub fn rem_self_t(&mut self, value: T); pub fn rem_self_s(&mut self, value: T);
pub fn add_self_v(&mut self, other: &Self); pub fn add_self_v(&mut self, other: &Self);
pub fn sub_self_v(&mut self, other: &Self); pub fn sub_self_v(&mut self, other: &Self);
@ -69,18 +69,18 @@ pub trait FloatVec<T,Slice>: NumVec<T,Slice> + ApproxEq<T> {
/// Vectors with orderable components /// Vectors with orderable components
pub trait OrdVec<T,Slice,BV>: Vec<T,Slice> { pub trait OrdVec<T,Slice,BV>: Vec<T,Slice> {
pub fn lt_t(&self, value: T) -> BV; pub fn lt_s(&self, value: T) -> BV;
pub fn le_t(&self, value: T) -> BV; pub fn le_s(&self, value: T) -> BV;
pub fn ge_t(&self, value: T) -> BV; pub fn ge_s(&self, value: T) -> BV;
pub fn gt_t(&self, value: T) -> BV; pub fn gt_s(&self, value: T) -> BV;
pub fn lt_v(&self, other: &Self) -> BV; pub fn lt_v(&self, other: &Self) -> BV;
pub fn le_v(&self, other: &Self) -> BV; pub fn le_v(&self, other: &Self) -> BV;
pub fn ge_v(&self, other: &Self) -> BV; pub fn ge_v(&self, other: &Self) -> BV;
pub fn gt_v(&self, other: &Self) -> BV; pub fn gt_v(&self, other: &Self) -> BV;
pub fn min_t(&self, other: T) -> Self; pub fn min_s(&self, other: T) -> Self;
pub fn max_t(&self, other: T) -> Self; pub fn max_s(&self, other: T) -> Self;
pub fn min_v(&self, other: &Self) -> Self; pub fn min_v(&self, other: &Self) -> Self;
pub fn max_v(&self, other: &Self) -> Self; pub fn max_v(&self, other: &Self) -> Self;
@ -91,8 +91,8 @@ pub trait OrdVec<T,Slice,BV>: Vec<T,Slice> {
/// Vectors with components that can be tested for equality /// Vectors with components that can be tested for equality
pub trait EqVec<T,Slice,BV>: Eq { pub trait EqVec<T,Slice,BV>: Eq {
pub fn eq_t(&self, value: T) -> BV; pub fn eq_s(&self, value: T) -> BV;
pub fn ne_t(&self, value: T) -> BV; pub fn ne_s(&self, value: T) -> BV;
pub fn eq_v(&self, other: &Self) -> BV; pub fn eq_v(&self, other: &Self) -> BV;
pub fn ne_v(&self, other: &Self) -> BV; pub fn ne_v(&self, other: &Self) -> BV;
} }
@ -211,35 +211,35 @@ impl<T> Vec<T,[T,..2]> for Vec2<T> {}
impl<T:Num> NumVec<T,[T,..2]> for Vec2<T> { impl<T:Num> NumVec<T,[T,..2]> for Vec2<T> {
/// Returns a new vector with `value` added to each component. /// Returns a new vector with `value` added to each component.
#[inline] #[inline]
pub fn add_t(&self, value: T) -> Vec2<T> { pub fn add_s(&self, value: T) -> Vec2<T> {
Vec2::new(*self.index(0) + value, Vec2::new(*self.index(0) + value,
*self.index(1) + value) *self.index(1) + value)
} }
/// Returns a new vector with `value` subtracted from each component. /// Returns a new vector with `value` subtracted from each component.
#[inline] #[inline]
pub fn sub_t(&self, value: T) -> Vec2<T> { pub fn sub_s(&self, value: T) -> Vec2<T> {
Vec2::new(*self.index(0) - value, Vec2::new(*self.index(0) - value,
*self.index(1) - value) *self.index(1) - value)
} }
/// Returns the scalar multiplication of the vector with `value`. /// Returns the scalar multiplication of the vector with `value`.
#[inline] #[inline]
pub fn mul_t(&self, value: T) -> Vec2<T> { pub fn mul_s(&self, value: T) -> Vec2<T> {
Vec2::new(*self.index(0) * value, Vec2::new(*self.index(0) * value,
*self.index(1) * value) *self.index(1) * value)
} }
/// Returns a new vector with each component divided by `value`. /// Returns a new vector with each component divided by `value`.
#[inline] #[inline]
pub fn div_t(&self, value: T) -> Vec2<T> { pub fn div_s(&self, value: T) -> Vec2<T> {
Vec2::new(*self.index(0) / value, Vec2::new(*self.index(0) / value,
*self.index(1) / value) *self.index(1) / value)
} }
/// Returns the remainder of each component divided by `value`. /// Returns the remainder of each component divided by `value`.
#[inline] #[inline]
pub fn rem_t(&self, value: T) -> Vec2<T> { pub fn rem_s(&self, value: T) -> Vec2<T> {
Vec2::new(*self.index(0) % value, Vec2::new(*self.index(0) % value,
*self.index(1) % value) *self.index(1) % value)
} }
@ -288,32 +288,32 @@ impl<T:Num> NumVec<T,[T,..2]> for Vec2<T> {
/// Adds `value` to each component of the vector. /// Adds `value` to each component of the vector.
#[inline] #[inline]
pub fn add_self_t(&mut self, value: T) { pub fn add_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) + value; *self.index_mut(0) = *self.index(0) + value;
*self.index_mut(1) = *self.index(1) + value; *self.index_mut(1) = *self.index(1) + value;
} }
/// Subtracts `value` from each component of the vector. /// Subtracts `value` from each component of the vector.
#[inline] #[inline]
pub fn sub_self_t(&mut self, value: T) { pub fn sub_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) - value; *self.index_mut(0) = *self.index(0) - value;
*self.index_mut(1) = *self.index(1) - value; *self.index_mut(1) = *self.index(1) - value;
} }
#[inline] #[inline]
pub fn mul_self_t(&mut self, value: T) { pub fn mul_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) * value; *self.index_mut(0) = *self.index(0) * value;
*self.index_mut(1) = *self.index(1) * value; *self.index_mut(1) = *self.index(1) * value;
} }
#[inline] #[inline]
pub fn div_self_t(&mut self, value: T) { pub fn div_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) / value; *self.index_mut(0) = *self.index(0) / value;
*self.index_mut(1) = *self.index(1) / value; *self.index_mut(1) = *self.index(1) / value;
} }
#[inline] #[inline]
pub fn rem_self_t(&mut self, value: T) { pub fn rem_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) % value; *self.index_mut(0) = *self.index(0) % value;
*self.index_mut(1) = *self.index(1) % value; *self.index_mut(1) = *self.index(1) % value;
} }
@ -407,59 +407,59 @@ impl<T:Float> FloatVec<T,[T,..2]> for Vec2<T> {
/// Returns the result of normalizing the vector to `magnitude`. /// Returns the result of normalizing the vector to `magnitude`.
#[inline] #[inline]
pub fn normalize_to(&self, magnitude: T) -> Vec2<T> { pub fn normalize_to(&self, magnitude: T) -> Vec2<T> {
self.mul_t(magnitude / self.magnitude()) self.mul_s(magnitude / self.magnitude())
} }
/// Returns the result of linarly interpolating the magnitude of the vector /// Returns the result of linarly interpolating the magnitude of the vector
/// to the magnitude of `other` by the specified amount. /// to the magnitude of `other` by the specified amount.
#[inline] #[inline]
pub fn lerp(&self, other: &Vec2<T>, amount: T) -> Vec2<T> { pub fn lerp(&self, other: &Vec2<T>, amount: T) -> Vec2<T> {
self.add_v(&other.sub_v(self).mul_t(amount)) self.add_v(&other.sub_v(self).mul_s(amount))
} }
/// Normalises the vector to a magnitude of `1`. /// Normalises the vector to a magnitude of `1`.
#[inline] #[inline]
pub fn normalize_self(&mut self) { pub fn normalize_self(&mut self) {
let rlen = self.magnitude().recip(); let rlen = self.magnitude().recip();
self.mul_self_t(rlen); self.mul_self_s(rlen);
} }
/// Normalizes the vector to `magnitude`. /// Normalizes the vector to `magnitude`.
#[inline] #[inline]
pub fn normalize_self_to(&mut self, magnitude: T) { pub fn normalize_self_to(&mut self, magnitude: T) {
let n = magnitude / self.magnitude(); let n = magnitude / self.magnitude();
self.mul_self_t(n); self.mul_self_s(n);
} }
/// Linearly interpolates the magnitude of the vector to the magnitude of /// Linearly interpolates the magnitude of the vector to the magnitude of
/// `other` by the specified amount. /// `other` by the specified amount.
pub fn lerp_self(&mut self, other: &Vec2<T>, amount: T) { pub fn lerp_self(&mut self, other: &Vec2<T>, amount: T) {
let v = other.sub_v(self).mul_t(amount); let v = other.sub_v(self).mul_s(amount);
self.add_self_v(&v); self.add_self_v(&v);
} }
} }
impl<T:Orderable> OrdVec<T,[T,..2],Vec2<bool>> for Vec2<T> { impl<T:Orderable> OrdVec<T,[T,..2],Vec2<bool>> for Vec2<T> {
#[inline] #[inline]
pub fn lt_t(&self, value: T) -> Vec2<bool> { pub fn lt_s(&self, value: T) -> Vec2<bool> {
Vec2::new(*self.index(0) < value, Vec2::new(*self.index(0) < value,
*self.index(1) < value) *self.index(1) < value)
} }
#[inline] #[inline]
pub fn le_t(&self, value: T) -> Vec2<bool> { pub fn le_s(&self, value: T) -> Vec2<bool> {
Vec2::new(*self.index(0) <= value, Vec2::new(*self.index(0) <= value,
*self.index(1) <= value) *self.index(1) <= value)
} }
#[inline] #[inline]
pub fn ge_t(&self, value: T) -> Vec2<bool> { pub fn ge_s(&self, value: T) -> Vec2<bool> {
Vec2::new(*self.index(0) >= value, Vec2::new(*self.index(0) >= value,
*self.index(1) >= value) *self.index(1) >= value)
} }
#[inline] #[inline]
pub fn gt_t(&self, value: T) -> Vec2<bool> { pub fn gt_s(&self, value: T) -> Vec2<bool> {
Vec2::new(*self.index(0) > value, Vec2::new(*self.index(0) > value,
*self.index(1) > value) *self.index(1) > value)
} }
@ -489,13 +489,13 @@ impl<T:Orderable> OrdVec<T,[T,..2],Vec2<bool>> for Vec2<T> {
} }
#[inline] #[inline]
pub fn min_t(&self, value: T) -> Vec2<T> { pub fn min_s(&self, value: T) -> Vec2<T> {
Vec2::new(self.index(0).min(&value), Vec2::new(self.index(0).min(&value),
self.index(1).min(&value)) self.index(1).min(&value))
} }
#[inline] #[inline]
pub fn max_t(&self, value: T) -> Vec2<T> { pub fn max_s(&self, value: T) -> Vec2<T> {
Vec2::new(self.index(0).max(&value), Vec2::new(self.index(0).max(&value),
self.index(1).max(&value)) self.index(1).max(&value))
} }
@ -527,13 +527,13 @@ impl<T:Orderable> OrdVec<T,[T,..2],Vec2<bool>> for Vec2<T> {
impl<T:Eq> EqVec<T,[T,..2],Vec2<bool>> for Vec2<T> { impl<T:Eq> EqVec<T,[T,..2],Vec2<bool>> for Vec2<T> {
#[inline] #[inline]
pub fn eq_t(&self, value: T) -> Vec2<bool> { pub fn eq_s(&self, value: T) -> Vec2<bool> {
Vec2::new(*self.index(0) == value, Vec2::new(*self.index(0) == value,
*self.index(1) == value) *self.index(1) == value)
} }
#[inline] #[inline]
pub fn ne_t(&self, value: T) -> Vec2<bool> { pub fn ne_s(&self, value: T) -> Vec2<bool> {
Vec2::new(*self.index(0) != value, Vec2::new(*self.index(0) != value,
*self.index(1) != value) *self.index(1) != value)
} }
@ -599,8 +599,8 @@ mod vec2_tests {
assert_eq!(-A, Vec2::new::<float>(-1.0, -2.0)); assert_eq!(-A, Vec2::new::<float>(-1.0, -2.0));
assert_eq!(A.neg(), Vec2::new::<float>(-1.0, -2.0)); assert_eq!(A.neg(), Vec2::new::<float>(-1.0, -2.0));
assert_eq!(A.mul_t(F1), Vec2::new::<float>(1.5, 3.0)); assert_eq!(A.mul_s(F1), Vec2::new::<float>(1.5, 3.0));
assert_eq!(A.div_t(F2), Vec2::new::<float>(2.0, 4.0)); assert_eq!(A.div_s(F2), Vec2::new::<float>(2.0, 4.0));
assert_eq!(A.add_v(&B), Vec2::new::<float>(4.0, 6.0)); assert_eq!(A.add_v(&B), Vec2::new::<float>(4.0, 6.0));
assert_eq!(A.sub_v(&B), Vec2::new::<float>(-2.0, -2.0)); assert_eq!(A.sub_v(&B), Vec2::new::<float>(-2.0, -2.0));
@ -611,12 +611,12 @@ mod vec2_tests {
assert_eq!(mut_a, -A); assert_eq!(mut_a, -A);
mut_a = A; mut_a = A;
mut_a.mul_self_t(F1); mut_a.mul_self_s(F1);
assert_eq!(mut_a, A.mul_t(F1)); assert_eq!(mut_a, A.mul_s(F1));
mut_a = A; mut_a = A;
mut_a.div_self_t(F2); mut_a.div_self_s(F2);
assert_eq!(mut_a, A.div_t(F2)); assert_eq!(mut_a, A.div_s(F2));
mut_a = A; mut_a = A;
mut_a.add_self_v(&B); mut_a.add_self_v(&B);
@ -846,7 +846,7 @@ impl<T> Vec<T,[T,..3]> for Vec3<T> {}
impl<T:Num> NumVec<T,[T,..3]> for Vec3<T> { impl<T:Num> NumVec<T,[T,..3]> for Vec3<T> {
/// Returns a new vector with `value` added to each component. /// Returns a new vector with `value` added to each component.
#[inline] #[inline]
pub fn add_t(&self, value: T) -> Vec3<T> { pub fn add_s(&self, value: T) -> Vec3<T> {
Vec3::new(*self.index(0) + value, Vec3::new(*self.index(0) + value,
*self.index(1) + value, *self.index(1) + value,
*self.index(2) + value) *self.index(2) + value)
@ -854,7 +854,7 @@ impl<T:Num> NumVec<T,[T,..3]> for Vec3<T> {
/// Returns a new vector with `value` subtracted from each component. /// Returns a new vector with `value` subtracted from each component.
#[inline] #[inline]
pub fn sub_t(&self, value: T) -> Vec3<T> { pub fn sub_s(&self, value: T) -> Vec3<T> {
Vec3::new(*self.index(0) - value, Vec3::new(*self.index(0) - value,
*self.index(1) - value, *self.index(1) - value,
*self.index(2) - value) *self.index(2) - value)
@ -862,7 +862,7 @@ impl<T:Num> NumVec<T,[T,..3]> for Vec3<T> {
/// Returns the scalar multiplication of the vector with `value`. /// Returns the scalar multiplication of the vector with `value`.
#[inline] #[inline]
pub fn mul_t(&self, value: T) -> Vec3<T> { pub fn mul_s(&self, value: T) -> Vec3<T> {
Vec3::new(*self.index(0) * value, Vec3::new(*self.index(0) * value,
*self.index(1) * value, *self.index(1) * value,
*self.index(2) * value) *self.index(2) * value)
@ -870,7 +870,7 @@ impl<T:Num> NumVec<T,[T,..3]> for Vec3<T> {
/// Returns a new vector with each component divided by `value`. /// Returns a new vector with each component divided by `value`.
#[inline] #[inline]
pub fn div_t(&self, value: T) -> Vec3<T> { pub fn div_s(&self, value: T) -> Vec3<T> {
Vec3::new(*self.index(0) / value, Vec3::new(*self.index(0) / value,
*self.index(1) / value, *self.index(1) / value,
*self.index(2) / value) *self.index(2) / value)
@ -878,7 +878,7 @@ impl<T:Num> NumVec<T,[T,..3]> for Vec3<T> {
/// Returns the remainder of each component divided by `value`. /// Returns the remainder of each component divided by `value`.
#[inline] #[inline]
pub fn rem_t(&self, value: T) -> Vec3<T> { pub fn rem_s(&self, value: T) -> Vec3<T> {
Vec3::new(*self.index(0) % value, Vec3::new(*self.index(0) % value,
*self.index(1) % value, *self.index(1) % value,
*self.index(2) % value) *self.index(2) % value)
@ -934,7 +934,7 @@ impl<T:Num> NumVec<T,[T,..3]> for Vec3<T> {
/// Adds `value` to each component of the vector. /// Adds `value` to each component of the vector.
#[inline] #[inline]
pub fn add_self_t(&mut self, value: T) { pub fn add_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) + value; *self.index_mut(0) = *self.index(0) + value;
*self.index_mut(1) = *self.index(1) + value; *self.index_mut(1) = *self.index(1) + value;
*self.index_mut(2) = *self.index(2) + value; *self.index_mut(2) = *self.index(2) + value;
@ -942,28 +942,28 @@ impl<T:Num> NumVec<T,[T,..3]> for Vec3<T> {
/// Subtracts `value` from each component of the vector. /// Subtracts `value` from each component of the vector.
#[inline] #[inline]
pub fn sub_self_t(&mut self, value: T) { pub fn sub_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) - value; *self.index_mut(0) = *self.index(0) - value;
*self.index_mut(1) = *self.index(1) - value; *self.index_mut(1) = *self.index(1) - value;
*self.index_mut(2) = *self.index(2) - value; *self.index_mut(2) = *self.index(2) - value;
} }
#[inline] #[inline]
pub fn mul_self_t(&mut self, value: T) { pub fn mul_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) * value; *self.index_mut(0) = *self.index(0) * value;
*self.index_mut(1) = *self.index(1) * value; *self.index_mut(1) = *self.index(1) * value;
*self.index_mut(2) = *self.index(2) * value; *self.index_mut(2) = *self.index(2) * value;
} }
#[inline] #[inline]
pub fn div_self_t(&mut self, value: T) { pub fn div_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) / value; *self.index_mut(0) = *self.index(0) / value;
*self.index_mut(1) = *self.index(1) / value; *self.index_mut(1) = *self.index(1) / value;
*self.index_mut(2) = *self.index(2) / value; *self.index_mut(2) = *self.index(2) / value;
} }
#[inline] #[inline]
pub fn rem_self_t(&mut self, value: T) { pub fn rem_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) % value; *self.index_mut(0) = *self.index(0) % value;
*self.index_mut(1) = *self.index(1) % value; *self.index_mut(1) = *self.index(1) % value;
*self.index_mut(2) = *self.index(2) % value; *self.index_mut(2) = *self.index(2) % value;
@ -1065,62 +1065,62 @@ impl<T:Float> FloatVec<T,[T,..3]> for Vec3<T> {
/// Returns the result of normalizing the vector to `magnitude`. /// Returns the result of normalizing the vector to `magnitude`.
#[inline] #[inline]
pub fn normalize_to(&self, magnitude: T) -> Vec3<T> { pub fn normalize_to(&self, magnitude: T) -> Vec3<T> {
self.mul_t(magnitude / self.magnitude()) self.mul_s(magnitude / self.magnitude())
} }
/// Returns the result of linarly interpolating the magnitude of the vector /// Returns the result of linarly interpolating the magnitude of the vector
/// to the magnitude of `other` by the specified amount. /// to the magnitude of `other` by the specified amount.
#[inline] #[inline]
pub fn lerp(&self, other: &Vec3<T>, amount: T) -> Vec3<T> { pub fn lerp(&self, other: &Vec3<T>, amount: T) -> Vec3<T> {
self.add_v(&other.sub_v(self).mul_t(amount)) self.add_v(&other.sub_v(self).mul_s(amount))
} }
/// Normalises the vector to a magnitude of `1`. /// Normalises the vector to a magnitude of `1`.
#[inline] #[inline]
pub fn normalize_self(&mut self) { pub fn normalize_self(&mut self) {
let rlen = self.magnitude().recip(); let rlen = self.magnitude().recip();
self.mul_self_t(rlen); self.mul_self_s(rlen);
} }
/// Normalizes the vector to `magnitude`. /// Normalizes the vector to `magnitude`.
#[inline] #[inline]
pub fn normalize_self_to(&mut self, magnitude: T) { pub fn normalize_self_to(&mut self, magnitude: T) {
let n = magnitude / self.magnitude(); let n = magnitude / self.magnitude();
self.mul_self_t(n); self.mul_self_s(n);
} }
/// Linearly interpolates the magnitude of the vector to the magnitude of /// Linearly interpolates the magnitude of the vector to the magnitude of
/// `other` by the specified amount. /// `other` by the specified amount.
pub fn lerp_self(&mut self, other: &Vec3<T>, amount: T) { pub fn lerp_self(&mut self, other: &Vec3<T>, amount: T) {
let v = other.sub_v(self).mul_t(amount); let v = other.sub_v(self).mul_s(amount);
self.add_self_v(&v); self.add_self_v(&v);
} }
} }
impl<T:Orderable> OrdVec<T,[T,..3],Vec3<bool>> for Vec3<T> { impl<T:Orderable> OrdVec<T,[T,..3],Vec3<bool>> for Vec3<T> {
#[inline] #[inline]
pub fn lt_t(&self, value: T) -> Vec3<bool> { pub fn lt_s(&self, value: T) -> Vec3<bool> {
Vec3::new(*self.index(0) < value, Vec3::new(*self.index(0) < value,
*self.index(1) < value, *self.index(1) < value,
*self.index(2) < value) *self.index(2) < value)
} }
#[inline] #[inline]
pub fn le_t(&self, value: T) -> Vec3<bool> { pub fn le_s(&self, value: T) -> Vec3<bool> {
Vec3::new(*self.index(0) <= value, Vec3::new(*self.index(0) <= value,
*self.index(1) <= value, *self.index(1) <= value,
*self.index(2) <= value) *self.index(2) <= value)
} }
#[inline] #[inline]
pub fn ge_t(&self, value: T) -> Vec3<bool> { pub fn ge_s(&self, value: T) -> Vec3<bool> {
Vec3::new(*self.index(0) >= value, Vec3::new(*self.index(0) >= value,
*self.index(1) >= value, *self.index(1) >= value,
*self.index(2) >= value) *self.index(2) >= value)
} }
#[inline] #[inline]
pub fn gt_t(&self, value: T) -> Vec3<bool> { pub fn gt_s(&self, value: T) -> Vec3<bool> {
Vec3::new(*self.index(0) > value, Vec3::new(*self.index(0) > value,
*self.index(1) > value, *self.index(1) > value,
*self.index(2) > value) *self.index(2) > value)
@ -1155,14 +1155,14 @@ impl<T:Orderable> OrdVec<T,[T,..3],Vec3<bool>> for Vec3<T> {
} }
#[inline] #[inline]
pub fn min_t(&self, value: T) -> Vec3<T> { pub fn min_s(&self, value: T) -> Vec3<T> {
Vec3::new(self.index(0).min(&value), Vec3::new(self.index(0).min(&value),
self.index(1).min(&value), self.index(1).min(&value),
self.index(2).min(&value)) self.index(2).min(&value))
} }
#[inline] #[inline]
pub fn max_t(&self, value: T) -> Vec3<T> { pub fn max_s(&self, value: T) -> Vec3<T> {
Vec3::new(self.index(0).max(&value), Vec3::new(self.index(0).max(&value),
self.index(1).max(&value), self.index(1).max(&value),
self.index(2).max(&value)) self.index(2).max(&value))
@ -1197,14 +1197,14 @@ impl<T:Orderable> OrdVec<T,[T,..3],Vec3<bool>> for Vec3<T> {
impl<T:Eq> EqVec<T,[T,..3],Vec3<bool>> for Vec3<T> { impl<T:Eq> EqVec<T,[T,..3],Vec3<bool>> for Vec3<T> {
#[inline] #[inline]
pub fn eq_t(&self, value: T) -> Vec3<bool> { pub fn eq_s(&self, value: T) -> Vec3<bool> {
Vec3::new(*self.index(0) == value, Vec3::new(*self.index(0) == value,
*self.index(1) == value, *self.index(1) == value,
*self.index(2) == value) *self.index(2) == value)
} }
#[inline] #[inline]
pub fn ne_t(&self, value: T) -> Vec3<bool> { pub fn ne_s(&self, value: T) -> Vec3<bool> {
Vec3::new(*self.index(0) != value, Vec3::new(*self.index(0) != value,
*self.index(1) != value, *self.index(1) != value,
*self.index(2) != value) *self.index(2) != value)
@ -1289,8 +1289,8 @@ mod vec3_tests{
assert_eq!(-A, Vec3::new::<float>(-1.0, -2.0, -3.0)); assert_eq!(-A, Vec3::new::<float>(-1.0, -2.0, -3.0));
assert_eq!(A.neg(), Vec3::new::<float>(-1.0, -2.0, -3.0)); assert_eq!(A.neg(), Vec3::new::<float>(-1.0, -2.0, -3.0));
assert_eq!(A.mul_t(F1), Vec3::new::<float>(1.5, 3.0, 4.5)); assert_eq!(A.mul_s(F1), Vec3::new::<float>(1.5, 3.0, 4.5));
assert_eq!(A.div_t(F2), Vec3::new::<float>(2.0, 4.0, 6.0)); assert_eq!(A.div_s(F2), Vec3::new::<float>(2.0, 4.0, 6.0));
assert_eq!(A.add_v(&B), Vec3::new::<float>(5.0, 7.0, 9.0)); assert_eq!(A.add_v(&B), Vec3::new::<float>(5.0, 7.0, 9.0));
assert_eq!(A.sub_v(&B), Vec3::new::<float>(-3.0, -3.0, -3.0)); assert_eq!(A.sub_v(&B), Vec3::new::<float>(-3.0, -3.0, -3.0));
@ -1301,12 +1301,12 @@ mod vec3_tests{
assert_eq!(mut_a, -A); assert_eq!(mut_a, -A);
mut_a = A; mut_a = A;
mut_a.mul_self_t(F1); mut_a.mul_self_s(F1);
assert_eq!(mut_a, A.mul_t(F1)); assert_eq!(mut_a, A.mul_s(F1));
mut_a = A; mut_a = A;
mut_a.div_self_t(F2); mut_a.div_self_s(F2);
assert_eq!(mut_a, A.div_t(F2)); assert_eq!(mut_a, A.div_s(F2));
mut_a = A; mut_a = A;
mut_a.add_self_v(&B); mut_a.add_self_v(&B);
@ -1515,7 +1515,7 @@ impl<T> Vec<T,[T,..4]> for Vec4<T> {}
impl<T:Num> NumVec<T,[T,..4]> for Vec4<T> { impl<T:Num> NumVec<T,[T,..4]> for Vec4<T> {
/// Returns a new vector with `value` added to each component. /// Returns a new vector with `value` added to each component.
#[inline] #[inline]
pub fn add_t(&self, value: T) -> Vec4<T> { pub fn add_s(&self, value: T) -> Vec4<T> {
Vec4::new(*self.index(0) + value, Vec4::new(*self.index(0) + value,
*self.index(1) + value, *self.index(1) + value,
*self.index(2) + value, *self.index(2) + value,
@ -1524,7 +1524,7 @@ impl<T:Num> NumVec<T,[T,..4]> for Vec4<T> {
/// Returns a new vector with `value` subtracted from each component. /// Returns a new vector with `value` subtracted from each component.
#[inline] #[inline]
pub fn sub_t(&self, value: T) -> Vec4<T> { pub fn sub_s(&self, value: T) -> Vec4<T> {
Vec4::new(*self.index(0) - value, Vec4::new(*self.index(0) - value,
*self.index(1) - value, *self.index(1) - value,
*self.index(2) - value, *self.index(2) - value,
@ -1533,7 +1533,7 @@ impl<T:Num> NumVec<T,[T,..4]> for Vec4<T> {
/// Returns the scalar multiplication of the vector with `value`. /// Returns the scalar multiplication of the vector with `value`.
#[inline] #[inline]
pub fn mul_t(&self, value: T) -> Vec4<T> { pub fn mul_s(&self, value: T) -> Vec4<T> {
Vec4::new(*self.index(0) * value, Vec4::new(*self.index(0) * value,
*self.index(1) * value, *self.index(1) * value,
*self.index(2) * value, *self.index(2) * value,
@ -1542,7 +1542,7 @@ impl<T:Num> NumVec<T,[T,..4]> for Vec4<T> {
/// Returns a new vector with each component divided by `value`. /// Returns a new vector with each component divided by `value`.
#[inline] #[inline]
pub fn div_t(&self, value: T) -> Vec4<T> { pub fn div_s(&self, value: T) -> Vec4<T> {
Vec4::new(*self.index(0) / value, Vec4::new(*self.index(0) / value,
*self.index(1) / value, *self.index(1) / value,
*self.index(2) / value, *self.index(2) / value,
@ -1551,7 +1551,7 @@ impl<T:Num> NumVec<T,[T,..4]> for Vec4<T> {
/// Returns the remainder of each component divided by `value`. /// Returns the remainder of each component divided by `value`.
#[inline] #[inline]
pub fn rem_t(&self, value: T) -> Vec4<T> { pub fn rem_s(&self, value: T) -> Vec4<T> {
Vec4::new(*self.index(0) % value, Vec4::new(*self.index(0) % value,
*self.index(1) % value, *self.index(1) % value,
*self.index(2) % value, *self.index(2) % value,
@ -1614,7 +1614,7 @@ impl<T:Num> NumVec<T,[T,..4]> for Vec4<T> {
/// Adds `value` to each component of the vector. /// Adds `value` to each component of the vector.
#[inline] #[inline]
pub fn add_self_t(&mut self, value: T) { pub fn add_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) + value; *self.index_mut(0) = *self.index(0) + value;
*self.index_mut(1) = *self.index(1) + value; *self.index_mut(1) = *self.index(1) + value;
*self.index_mut(2) = *self.index(2) + value; *self.index_mut(2) = *self.index(2) + value;
@ -1623,7 +1623,7 @@ impl<T:Num> NumVec<T,[T,..4]> for Vec4<T> {
/// Subtracts `value` from each component of the vector. /// Subtracts `value` from each component of the vector.
#[inline] #[inline]
pub fn sub_self_t(&mut self, value: T) { pub fn sub_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) - value; *self.index_mut(0) = *self.index(0) - value;
*self.index_mut(1) = *self.index(1) - value; *self.index_mut(1) = *self.index(1) - value;
*self.index_mut(2) = *self.index(2) - value; *self.index_mut(2) = *self.index(2) - value;
@ -1631,7 +1631,7 @@ impl<T:Num> NumVec<T,[T,..4]> for Vec4<T> {
} }
#[inline] #[inline]
pub fn mul_self_t(&mut self, value: T) { pub fn mul_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) * value; *self.index_mut(0) = *self.index(0) * value;
*self.index_mut(1) = *self.index(1) * value; *self.index_mut(1) = *self.index(1) * value;
*self.index_mut(2) = *self.index(2) * value; *self.index_mut(2) = *self.index(2) * value;
@ -1639,7 +1639,7 @@ impl<T:Num> NumVec<T,[T,..4]> for Vec4<T> {
} }
#[inline] #[inline]
pub fn div_self_t(&mut self, value: T) { pub fn div_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) / value; *self.index_mut(0) = *self.index(0) / value;
*self.index_mut(1) = *self.index(1) / value; *self.index_mut(1) = *self.index(1) / value;
*self.index_mut(2) = *self.index(2) / value; *self.index_mut(2) = *self.index(2) / value;
@ -1647,7 +1647,7 @@ impl<T:Num> NumVec<T,[T,..4]> for Vec4<T> {
} }
#[inline] #[inline]
pub fn rem_self_t(&mut self, value: T) { pub fn rem_self_s(&mut self, value: T) {
*self.index_mut(0) = *self.index(0) % value; *self.index_mut(0) = *self.index(0) % value;
*self.index_mut(1) = *self.index(1) % value; *self.index_mut(1) = *self.index(1) % value;
*self.index_mut(2) = *self.index(2) % value; *self.index_mut(2) = *self.index(2) % value;
@ -1757,41 +1757,41 @@ impl<T:Float> FloatVec<T,[T,..4]> for Vec4<T> {
/// Returns the result of normalizing the vector to `magnitude`. /// Returns the result of normalizing the vector to `magnitude`.
#[inline] #[inline]
pub fn normalize_to(&self, magnitude: T) -> Vec4<T> { pub fn normalize_to(&self, magnitude: T) -> Vec4<T> {
self.mul_t(magnitude / self.magnitude()) self.mul_s(magnitude / self.magnitude())
} }
/// Returns the result of linarly interpolating the magnitude of the vector /// Returns the result of linarly interpolating the magnitude of the vector
/// to the magnitude of `other` by the specified amount. /// to the magnitude of `other` by the specified amount.
#[inline] #[inline]
pub fn lerp(&self, other: &Vec4<T>, amount: T) -> Vec4<T> { pub fn lerp(&self, other: &Vec4<T>, amount: T) -> Vec4<T> {
self.add_v(&other.sub_v(self).mul_t(amount)) self.add_v(&other.sub_v(self).mul_s(amount))
} }
/// Normalises the vector to a magnitude of `1`. /// Normalises the vector to a magnitude of `1`.
#[inline] #[inline]
pub fn normalize_self(&mut self) { pub fn normalize_self(&mut self) {
let rlen = self.magnitude().recip(); let rlen = self.magnitude().recip();
self.mul_self_t(rlen); self.mul_self_s(rlen);
} }
/// Normalizes the vector to `magnitude`. /// Normalizes the vector to `magnitude`.
#[inline] #[inline]
pub fn normalize_self_to(&mut self, magnitude: T) { pub fn normalize_self_to(&mut self, magnitude: T) {
let n = magnitude / self.magnitude(); let n = magnitude / self.magnitude();
self.mul_self_t(n); self.mul_self_s(n);
} }
/// Linearly interpolates the magnitude of the vector to the magnitude of /// Linearly interpolates the magnitude of the vector to the magnitude of
/// `other` by the specified amount. /// `other` by the specified amount.
pub fn lerp_self(&mut self, other: &Vec4<T>, amount: T) { pub fn lerp_self(&mut self, other: &Vec4<T>, amount: T) {
let v = other.sub_v(self).mul_t(amount); let v = other.sub_v(self).mul_s(amount);
self.add_self_v(&v); self.add_self_v(&v);
} }
} }
impl<T:Orderable> OrdVec<T,[T,..4],Vec4<bool>> for Vec4<T> { impl<T:Orderable> OrdVec<T,[T,..4],Vec4<bool>> for Vec4<T> {
#[inline] #[inline]
pub fn lt_t(&self, value: T) -> Vec4<bool> { pub fn lt_s(&self, value: T) -> Vec4<bool> {
Vec4::new(*self.index(0) < value, Vec4::new(*self.index(0) < value,
*self.index(1) < value, *self.index(1) < value,
*self.index(2) < value, *self.index(2) < value,
@ -1799,7 +1799,7 @@ impl<T:Orderable> OrdVec<T,[T,..4],Vec4<bool>> for Vec4<T> {
} }
#[inline] #[inline]
pub fn le_t(&self, value: T) -> Vec4<bool> { pub fn le_s(&self, value: T) -> Vec4<bool> {
Vec4::new(*self.index(0) <= value, Vec4::new(*self.index(0) <= value,
*self.index(1) <= value, *self.index(1) <= value,
*self.index(2) <= value, *self.index(2) <= value,
@ -1807,7 +1807,7 @@ impl<T:Orderable> OrdVec<T,[T,..4],Vec4<bool>> for Vec4<T> {
} }
#[inline] #[inline]
pub fn ge_t(&self, value: T) -> Vec4<bool> { pub fn ge_s(&self, value: T) -> Vec4<bool> {
Vec4::new(*self.index(0) >= value, Vec4::new(*self.index(0) >= value,
*self.index(1) >= value, *self.index(1) >= value,
*self.index(2) >= value, *self.index(2) >= value,
@ -1815,7 +1815,7 @@ impl<T:Orderable> OrdVec<T,[T,..4],Vec4<bool>> for Vec4<T> {
} }
#[inline] #[inline]
pub fn gt_t(&self, value: T) -> Vec4<bool> { pub fn gt_s(&self, value: T) -> Vec4<bool> {
Vec4::new(*self.index(0) > value, Vec4::new(*self.index(0) > value,
*self.index(1) > value, *self.index(1) > value,
*self.index(2) > value, *self.index(2) > value,
@ -1855,7 +1855,7 @@ impl<T:Orderable> OrdVec<T,[T,..4],Vec4<bool>> for Vec4<T> {
} }
#[inline] #[inline]
pub fn min_t(&self, value: T) -> Vec4<T> { pub fn min_s(&self, value: T) -> Vec4<T> {
Vec4::new(self.index(0).min(&value), Vec4::new(self.index(0).min(&value),
self.index(1).min(&value), self.index(1).min(&value),
self.index(2).min(&value), self.index(2).min(&value),
@ -1863,7 +1863,7 @@ impl<T:Orderable> OrdVec<T,[T,..4],Vec4<bool>> for Vec4<T> {
} }
#[inline] #[inline]
pub fn max_t(&self, value: T) -> Vec4<T> { pub fn max_s(&self, value: T) -> Vec4<T> {
Vec4::new(self.index(0).max(&value), Vec4::new(self.index(0).max(&value),
self.index(1).max(&value), self.index(1).max(&value),
self.index(2).max(&value), self.index(2).max(&value),
@ -1901,7 +1901,7 @@ impl<T:Orderable> OrdVec<T,[T,..4],Vec4<bool>> for Vec4<T> {
impl<T:Eq> EqVec<T,[T,..4],Vec4<bool>> for Vec4<T> { impl<T:Eq> EqVec<T,[T,..4],Vec4<bool>> for Vec4<T> {
#[inline] #[inline]
pub fn eq_t(&self, value: T) -> Vec4<bool> { pub fn eq_s(&self, value: T) -> Vec4<bool> {
Vec4::new(*self.index(0) == value, Vec4::new(*self.index(0) == value,
*self.index(1) == value, *self.index(1) == value,
*self.index(2) == value, *self.index(2) == value,
@ -1909,7 +1909,7 @@ impl<T:Eq> EqVec<T,[T,..4],Vec4<bool>> for Vec4<T> {
} }
#[inline] #[inline]
pub fn ne_t(&self, value: T) -> Vec4<bool> { pub fn ne_s(&self, value: T) -> Vec4<bool> {
Vec4::new(*self.index(0) != value, Vec4::new(*self.index(0) != value,
*self.index(1) != value, *self.index(1) != value,
*self.index(2) != value, *self.index(2) != value,
@ -1988,8 +1988,8 @@ mod vec4_tests {
assert_eq!(-A, Vec4::new::<float>(-1.0, -2.0, -3.0, -4.0)); assert_eq!(-A, Vec4::new::<float>(-1.0, -2.0, -3.0, -4.0));
assert_eq!(A.neg(), Vec4::new::<float>(-1.0, -2.0, -3.0, -4.0)); assert_eq!(A.neg(), Vec4::new::<float>(-1.0, -2.0, -3.0, -4.0));
assert_eq!(A.mul_t(F1), Vec4::new::<float>(1.5, 3.0, 4.5, 6.0)); assert_eq!(A.mul_s(F1), Vec4::new::<float>(1.5, 3.0, 4.5, 6.0));
assert_eq!(A.div_t(F2), Vec4::new::<float>(2.0, 4.0, 6.0, 8.0)); assert_eq!(A.div_s(F2), Vec4::new::<float>(2.0, 4.0, 6.0, 8.0));
assert_eq!(A.add_v(&B), Vec4::new::<float>(6.0, 8.0, 10.0, 12.0)); assert_eq!(A.add_v(&B), Vec4::new::<float>(6.0, 8.0, 10.0, 12.0));
assert_eq!(A.sub_v(&B), Vec4::new::<float>(-4.0, -4.0, -4.0, -4.0)); assert_eq!(A.sub_v(&B), Vec4::new::<float>(-4.0, -4.0, -4.0, -4.0));
@ -2002,12 +2002,12 @@ mod vec4_tests {
assert_eq!(mut_a, -A); assert_eq!(mut_a, -A);
mut_a = A; mut_a = A;
mut_a.mul_self_t(F1); mut_a.mul_self_s(F1);
assert_eq!(mut_a, A.mul_t(F1)); assert_eq!(mut_a, A.mul_s(F1));
mut_a = A; mut_a = A;
mut_a.div_self_t(F2); mut_a.div_self_s(F2);
assert_eq!(mut_a, A.div_t(F2)); assert_eq!(mut_a, A.div_s(F2));
mut_a = A; mut_a = A;
mut_a.add_self_v(&B); mut_a.add_self_v(&B);

View file

@ -389,7 +389,7 @@ impl<T:Float> Rotation3<T> for AxisAngle<T> {
impl<T:Float> ToQuat<T> for AxisAngle<T> { impl<T:Float> ToQuat<T> for AxisAngle<T> {
pub fn to_quat(&self) -> Quat<T> { pub fn to_quat(&self) -> Quat<T> {
let half = self.angle / two!(T); let half = self.angle / two!(T);
Quat::from_sv(half.cos(), self.axis.mul_t(half.sin())) Quat::from_sv(half.cos(), self.axis.mul_s(half.sin()))
} }
} }