diff --git a/src/bounds/aabb.rs b/src/bounds/aabb.rs index b29f792..ac1a5fa 100644 --- a/src/bounds/aabb.rs +++ b/src/bounds/aabb.rs @@ -36,7 +36,7 @@ impl AABB2 { pub fn from_bounds(mn: Point2, mx: Point2) -> AABB2 { AABB2 { 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, } @@ -62,7 +62,7 @@ impl AABB3 { pub fn from_bounds(mn: Point3, mx: Point3) -> AABB3 { AABB3 { 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, } diff --git a/src/math/mat.rs b/src/math/mat.rs index 5739cd6..c0462be 100644 --- a/src/math/mat.rs +++ b/src/math/mat.rs @@ -34,12 +34,12 @@ pub trait Mat: Dimensioned } pub trait NumMat: Mat + Neg { - 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 add_m(&self, other: &Self) -> Self; pub fn sub_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 sub_self_m(&mut self, other: &Self); pub fn dot(&self, other: &Self) -> T; @@ -202,9 +202,9 @@ impl Mat2 { impl NumMat,[Vec2,..2]> for Mat2 { #[inline] - pub fn mul_t(&self, value: T) -> Mat2 { - Mat2::from_cols(self.col(0).mul_t(value.clone()), - self.col(1).mul_t(value.clone())) + pub fn mul_s(&self, value: T) -> Mat2 { + Mat2::from_cols(self.col(0).mul_s(value.clone()), + self.col(1).mul_s(value.clone())) } #[inline] @@ -235,9 +235,9 @@ impl NumMat,[Vec2,..2]> for Mat2 { } #[inline] - pub fn mul_self_t(&mut self, value: T) { - self.col_mut(0).mul_self_t(value.clone()); - self.col_mut(1).mul_self_t(value.clone()); + pub fn mul_self_s(&mut self, value: T) { + self.col_mut(0).mul_self_s(value.clone()); + self.col_mut(1).mul_self_s(value.clone()); } #[inline] @@ -408,13 +408,13 @@ mod mat2_tests{ } #[test] - fn test_mul_t() { - assert_eq!(A.mul_t(F), + fn test_mul_s() { + assert_eq!(A.mul_s(F), Mat2::new::(0.5, 1.5, 1.0, 2.0)); let mut mut_a = A; - mut_a.mul_self_t(F); - assert_eq!(mut_a, A.mul_t(F)); + mut_a.mul_self_s(F); + assert_eq!(mut_a, A.mul_s(F)); } #[test] @@ -685,10 +685,10 @@ impl Mat3 { impl NumMat,[Vec3,..3]> for Mat3 { #[inline] - pub fn mul_t(&self, value: T) -> Mat3 { - Mat3::from_cols(self.col(0).mul_t(value.clone()), - self.col(1).mul_t(value.clone()), - self.col(2).mul_t(value.clone())) + pub fn mul_s(&self, value: T) -> Mat3 { + Mat3::from_cols(self.col(0).mul_s(value.clone()), + self.col(1).mul_s(value.clone()), + self.col(2).mul_s(value.clone())) } #[inline] @@ -728,10 +728,10 @@ impl NumMat,[Vec3,..3]> for Mat3 { } #[inline] - pub fn mul_self_t(&mut self, value: T) { - self.col_mut(0).mul_self_t(value.clone()); - self.col_mut(1).mul_self_t(value.clone()); - self.col_mut(2).mul_self_t(value.clone()); + pub fn mul_self_s(&mut self, value: T) { + self.col_mut(0).mul_self_s(value.clone()); + self.col_mut(1).mul_self_s(value.clone()); + self.col_mut(2).mul_self_s(value.clone()); } #[inline] @@ -851,9 +851,9 @@ impl FloatMat,[Vec4,..4]> for Mat3 { if d.approx_eq(&zero!(T)) { None } else { - Some(Mat3::from_cols(self.col(1).cross(self.col(2)).div_t(d.clone()), - self.col(2).cross(self.col(0)).div_t(d.clone()), - self.col(0).cross(self.col(1)).div_t(d.clone())).transpose()) + Some(Mat3::from_cols(self.col(1).cross(self.col(2)).div_s(d.clone()), + self.col(2).cross(self.col(0)).div_s(d.clone()), + self.col(0).cross(self.col(1)).div_s(d.clone())).transpose()) } } @@ -992,14 +992,14 @@ mod mat3_tests{ } #[test] - fn test_mul_t() { - assert_eq!(A.mul_t(F), + fn test_mul_s() { + assert_eq!(A.mul_s(F), Mat3::new::(0.5, 2.0, 3.5, 1.0, 2.5, 4.0, 1.5, 3.0, 4.5)); let mut mut_a = A; - mut_a.mul_self_t(F); - assert_eq!(mut_a, A.mul_t(F)); + mut_a.mul_self_s(F); + assert_eq!(mut_a, A.mul_s(F)); } #[test] @@ -1275,11 +1275,11 @@ impl Mat4 { impl NumMat,[Vec4,..4]> for Mat4 { #[inline] - pub fn mul_t(&self, value: T) -> Mat4 { - Mat4::from_cols(self.col(0).mul_t(value.clone()), - self.col(1).mul_t(value.clone()), - self.col(2).mul_t(value.clone()), - self.col(3).mul_t(value.clone())) + pub fn mul_s(&self, value: T) -> Mat4 { + Mat4::from_cols(self.col(0).mul_s(value.clone()), + self.col(1).mul_s(value.clone()), + self.col(2).mul_s(value.clone()), + self.col(3).mul_s(value.clone())) } #[inline] @@ -1330,11 +1330,11 @@ impl NumMat,[Vec4,..4]> for Mat4 { } #[inline] - pub fn mul_self_t(&mut self, value: T) { - self.col_mut(0).mul_self_t(value.clone()); - self.col_mut(1).mul_self_t(value.clone()); - self.col_mut(2).mul_self_t(value.clone()); - self.col_mut(3).mul_self_t(value.clone()); + pub fn mul_self_s(&mut self, value: T) { + self.col_mut(0).mul_self_s(value.clone()); + self.col_mut(1).mul_self_s(value.clone()); + self.col_mut(2).mul_self_s(value.clone()); + self.col_mut(3).mul_self_s(value.clone()); } #[inline] @@ -1431,15 +1431,15 @@ impl FloatMat,[Vec4,..4]> for Mat4 { // Scale col j to have a unit diagonal let ajj = A.elem(j, j).clone(); - I.col_mut(j).div_self_t(ajj.clone()); - A.col_mut(j).div_self_t(ajj.clone()); + I.col_mut(j).div_self_s(ajj.clone()); + A.col_mut(j).div_self_s(ajj.clone()); // Eliminate off-diagonal elems in col j of A, // doing identical ops to I for uint::range(0, 4) |i| { if i != j { - let ij_mul_aij = I.col(j).mul_t(A.elem(i, j).clone()); - let aj_mul_aij = A.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_s(A.elem(i, j).clone()); I.col_mut(i).sub_self_v(&ij_mul_aij); A.col_mut(i).sub_self_v(&aj_mul_aij); } @@ -1605,15 +1605,15 @@ mod mat4_tests { } #[test] - fn test_mul_t() { - assert_eq!(A.mul_t(F), + fn test_mul_s() { + assert_eq!(A.mul_s(F), Mat4::new::(0.5, 2.5, 4.5, 6.5, 1.0, 3.0, 5.0, 7.0, 1.5, 3.5, 5.5, 7.5, 2.0, 4.0, 6.0, 8.0)); let mut mut_a = A; - mut_a.mul_self_t(F); - assert_eq!(mut_a, A.mul_t(F)); + mut_a.mul_self_s(F); + assert_eq!(mut_a, A.mul_s(F)); } #[test] @@ -1680,7 +1680,7 @@ mod mat4_tests { Mat4::new::( 5.0, -4.0, 1.0, 0.0, -4.0, 8.0, -4.0, 0.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; mut_c.invert_self(); assert_eq!(mut_c, C.inverse().unwrap()); diff --git a/src/math/quat.rs b/src/math/quat.rs index 78a684d..f382787 100644 --- a/src/math/quat.rs +++ b/src/math/quat.rs @@ -84,21 +84,21 @@ impl Quat { /// The result of multiplying the quaternion a scalar #[inline] - pub fn mul_t(&self, value: T) -> Quat { - Quat::from_sv(self.s * value, self.v.mul_t(value)) + pub fn mul_s(&self, value: T) -> Quat { + Quat::from_sv(self.s * value, self.v.mul_s(value)) } /// The result of dividing the quaternion a scalar #[inline] - pub fn div_t(&self, value: T) -> Quat { - Quat::from_sv(self.s / value, self.v.div_t(value)) + pub fn div_s(&self, value: T) -> Quat { + Quat::from_sv(self.s / value, self.v.div_s(value)) } /// The result of multiplying the quaternion by a vector #[inline] pub fn mul_v(&self, vec: &Vec3) -> Vec3 { - let tmp = self.v.cross(vec).add_v(&vec.mul_t(self.s.clone())); - self.v.cross(&tmp).mul_t(two!(T)).add_v(vec) + let tmp = self.v.cross(vec).add_v(&vec.mul_s(self.s.clone())); + self.v.cross(&tmp).mul_s(two!(T)).add_v(vec) } /// The sum of this quaternion and `other` @@ -142,7 +142,7 @@ impl Quat { /// The multiplicative inverse of the quaternion #[inline] pub fn inverse(&self) -> Quat { - self.conjugate().div_t(self.magnitude2()) + self.conjugate().div_s(self.magnitude2()) } /// The squared magnitude of the quaternion. This is useful for @@ -168,7 +168,7 @@ impl Quat { /// The normalized quaternion #[inline] pub fn normalize(&self) -> Quat { - self.mul_t(one!(T) / self.magnitude()) + self.mul_s(one!(T) / self.magnitude()) } /// Normalised linear interpolation @@ -177,7 +177,7 @@ impl Quat { /// /// The intoperlated quaternion pub fn nlerp(&self, other: &Quat, amount: T) -> Quat { - 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 Quat { let theta_0 = robust_dot.acos(); // the angle between the quaternions 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(); - self.mul_t(theta.cos()) - .add_q(&q.mul_t(theta.sin())) + self.mul_s(theta.cos()) + .add_q(&q.mul_s(theta.sin())) } } } diff --git a/src/math/vec.rs b/src/math/vec.rs index 5c55ef7..3371e83 100644 --- a/src/math/vec.rs +++ b/src/math/vec.rs @@ -23,11 +23,11 @@ pub trait Vec: Dimensioned /// Vectors with numeric components pub trait NumVec: Neg { - pub fn add_t(&self, value: T) -> Self; - pub fn sub_t(&self, value: T) -> Self; - pub fn mul_t(&self, value: T) -> Self; - pub fn div_t(&self, value: T) -> Self; - pub fn rem_t(&self, value: T) -> Self; + pub fn add_s(&self, value: T) -> Self; + pub fn sub_s(&self, value: T) -> Self; + pub fn mul_s(&self, value: T) -> Self; + pub fn div_s(&self, value: T) -> Self; + pub fn rem_s(&self, value: T) -> Self; pub fn add_v(&self, other: &Self) -> Self; pub fn sub_v(&self, other: &Self) -> Self; @@ -36,11 +36,11 @@ pub trait NumVec: Neg { pub fn rem_v(&self, other: &Self) -> Self; pub fn neg_self(&mut self); - pub fn add_self_t(&mut self, value: T); - pub fn sub_self_t(&mut self, value: T); - pub fn mul_self_t(&mut self, value: T); - pub fn div_self_t(&mut self, value: T); - pub fn rem_self_t(&mut self, value: T); + pub fn add_self_s(&mut self, value: T); + pub fn sub_self_s(&mut self, value: T); + pub fn mul_self_s(&mut self, value: T); + pub fn div_self_s(&mut self, value: T); + pub fn rem_self_s(&mut self, value: T); pub fn add_self_v(&mut self, other: &Self); pub fn sub_self_v(&mut self, other: &Self); @@ -69,18 +69,18 @@ pub trait FloatVec: NumVec + ApproxEq { /// Vectors with orderable components pub trait OrdVec: Vec { - pub fn lt_t(&self, value: T) -> BV; - pub fn le_t(&self, value: T) -> BV; - pub fn ge_t(&self, value: T) -> BV; - pub fn gt_t(&self, value: T) -> BV; + pub fn lt_s(&self, value: T) -> BV; + pub fn le_s(&self, value: T) -> BV; + pub fn ge_s(&self, value: T) -> BV; + pub fn gt_s(&self, value: T) -> BV; pub fn lt_v(&self, other: &Self) -> BV; pub fn le_v(&self, other: &Self) -> BV; pub fn ge_v(&self, other: &Self) -> BV; pub fn gt_v(&self, other: &Self) -> BV; - pub fn min_t(&self, other: T) -> Self; - pub fn max_t(&self, other: T) -> Self; + pub fn min_s(&self, other: T) -> Self; + pub fn max_s(&self, other: T) -> Self; pub fn min_v(&self, other: &Self) -> Self; pub fn max_v(&self, other: &Self) -> Self; @@ -91,8 +91,8 @@ pub trait OrdVec: Vec { /// Vectors with components that can be tested for equality pub trait EqVec: Eq { - pub fn eq_t(&self, value: T) -> BV; - pub fn ne_t(&self, value: T) -> BV; + pub fn eq_s(&self, value: T) -> BV; + pub fn ne_s(&self, value: T) -> BV; pub fn eq_v(&self, other: &Self) -> BV; pub fn ne_v(&self, other: &Self) -> BV; } @@ -211,35 +211,35 @@ impl Vec for Vec2 {} impl NumVec for Vec2 { /// Returns a new vector with `value` added to each component. #[inline] - pub fn add_t(&self, value: T) -> Vec2 { + pub fn add_s(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) + value, *self.index(1) + value) } /// Returns a new vector with `value` subtracted from each component. #[inline] - pub fn sub_t(&self, value: T) -> Vec2 { + pub fn sub_s(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) - value, *self.index(1) - value) } /// Returns the scalar multiplication of the vector with `value`. #[inline] - pub fn mul_t(&self, value: T) -> Vec2 { + pub fn mul_s(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) * value, *self.index(1) * value) } /// Returns a new vector with each component divided by `value`. #[inline] - pub fn div_t(&self, value: T) -> Vec2 { + pub fn div_s(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) / value, *self.index(1) / value) } /// Returns the remainder of each component divided by `value`. #[inline] - pub fn rem_t(&self, value: T) -> Vec2 { + pub fn rem_s(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) % value, *self.index(1) % value) } @@ -288,32 +288,32 @@ impl NumVec for Vec2 { /// Adds `value` to each component of the vector. #[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(1) = *self.index(1) + value; } /// Subtracts `value` from each component of the vector. #[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(1) = *self.index(1) - value; } #[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(1) = *self.index(1) * value; } #[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(1) = *self.index(1) / value; } #[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(1) = *self.index(1) % value; } @@ -407,59 +407,59 @@ impl FloatVec for Vec2 { /// Returns the result of normalizing the vector to `magnitude`. #[inline] pub fn normalize_to(&self, magnitude: T) -> Vec2 { - self.mul_t(magnitude / self.magnitude()) + self.mul_s(magnitude / self.magnitude()) } /// Returns the result of linarly interpolating the magnitude of the vector /// to the magnitude of `other` by the specified amount. #[inline] pub fn lerp(&self, other: &Vec2, amount: T) -> Vec2 { - 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`. #[inline] pub fn normalize_self(&mut self) { let rlen = self.magnitude().recip(); - self.mul_self_t(rlen); + self.mul_self_s(rlen); } /// Normalizes the vector to `magnitude`. #[inline] pub fn normalize_self_to(&mut self, magnitude: T) { 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 /// `other` by the specified amount. pub fn lerp_self(&mut self, other: &Vec2, 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); } } impl OrdVec> for Vec2 { #[inline] - pub fn lt_t(&self, value: T) -> Vec2 { + pub fn lt_s(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) < value, *self.index(1) < value) } #[inline] - pub fn le_t(&self, value: T) -> Vec2 { + pub fn le_s(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) <= value, *self.index(1) <= value) } #[inline] - pub fn ge_t(&self, value: T) -> Vec2 { + pub fn ge_s(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) >= value, *self.index(1) >= value) } #[inline] - pub fn gt_t(&self, value: T) -> Vec2 { + pub fn gt_s(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) > value, *self.index(1) > value) } @@ -489,13 +489,13 @@ impl OrdVec> for Vec2 { } #[inline] - pub fn min_t(&self, value: T) -> Vec2 { + pub fn min_s(&self, value: T) -> Vec2 { Vec2::new(self.index(0).min(&value), self.index(1).min(&value)) } #[inline] - pub fn max_t(&self, value: T) -> Vec2 { + pub fn max_s(&self, value: T) -> Vec2 { Vec2::new(self.index(0).max(&value), self.index(1).max(&value)) } @@ -527,13 +527,13 @@ impl OrdVec> for Vec2 { impl EqVec> for Vec2 { #[inline] - pub fn eq_t(&self, value: T) -> Vec2 { + pub fn eq_s(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) == value, *self.index(1) == value) } #[inline] - pub fn ne_t(&self, value: T) -> Vec2 { + pub fn ne_s(&self, value: T) -> Vec2 { Vec2::new(*self.index(0) != value, *self.index(1) != value) } @@ -599,8 +599,8 @@ mod vec2_tests { assert_eq!(-A, Vec2::new::(-1.0, -2.0)); assert_eq!(A.neg(), Vec2::new::(-1.0, -2.0)); - assert_eq!(A.mul_t(F1), Vec2::new::(1.5, 3.0)); - assert_eq!(A.div_t(F2), Vec2::new::(2.0, 4.0)); + assert_eq!(A.mul_s(F1), Vec2::new::(1.5, 3.0)); + assert_eq!(A.div_s(F2), Vec2::new::(2.0, 4.0)); assert_eq!(A.add_v(&B), Vec2::new::(4.0, 6.0)); assert_eq!(A.sub_v(&B), Vec2::new::(-2.0, -2.0)); @@ -611,12 +611,12 @@ mod vec2_tests { assert_eq!(mut_a, -A); mut_a = A; - mut_a.mul_self_t(F1); - assert_eq!(mut_a, A.mul_t(F1)); + mut_a.mul_self_s(F1); + assert_eq!(mut_a, A.mul_s(F1)); mut_a = A; - mut_a.div_self_t(F2); - assert_eq!(mut_a, A.div_t(F2)); + mut_a.div_self_s(F2); + assert_eq!(mut_a, A.div_s(F2)); mut_a = A; mut_a.add_self_v(&B); @@ -846,7 +846,7 @@ impl Vec for Vec3 {} impl NumVec for Vec3 { /// Returns a new vector with `value` added to each component. #[inline] - pub fn add_t(&self, value: T) -> Vec3 { + pub fn add_s(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) + value, *self.index(1) + value, *self.index(2) + value) @@ -854,7 +854,7 @@ impl NumVec for Vec3 { /// Returns a new vector with `value` subtracted from each component. #[inline] - pub fn sub_t(&self, value: T) -> Vec3 { + pub fn sub_s(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) - value, *self.index(1) - value, *self.index(2) - value) @@ -862,7 +862,7 @@ impl NumVec for Vec3 { /// Returns the scalar multiplication of the vector with `value`. #[inline] - pub fn mul_t(&self, value: T) -> Vec3 { + pub fn mul_s(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) * value, *self.index(1) * value, *self.index(2) * value) @@ -870,7 +870,7 @@ impl NumVec for Vec3 { /// Returns a new vector with each component divided by `value`. #[inline] - pub fn div_t(&self, value: T) -> Vec3 { + pub fn div_s(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) / value, *self.index(1) / value, *self.index(2) / value) @@ -878,7 +878,7 @@ impl NumVec for Vec3 { /// Returns the remainder of each component divided by `value`. #[inline] - pub fn rem_t(&self, value: T) -> Vec3 { + pub fn rem_s(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) % value, *self.index(1) % value, *self.index(2) % value) @@ -934,7 +934,7 @@ impl NumVec for Vec3 { /// Adds `value` to each component of the vector. #[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(1) = *self.index(1) + value; *self.index_mut(2) = *self.index(2) + value; @@ -942,28 +942,28 @@ impl NumVec for Vec3 { /// Subtracts `value` from each component of the vector. #[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(1) = *self.index(1) - value; *self.index_mut(2) = *self.index(2) - value; } #[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(1) = *self.index(1) * value; *self.index_mut(2) = *self.index(2) * value; } #[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(1) = *self.index(1) / value; *self.index_mut(2) = *self.index(2) / value; } #[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(1) = *self.index(1) % value; *self.index_mut(2) = *self.index(2) % value; @@ -1065,62 +1065,62 @@ impl FloatVec for Vec3 { /// Returns the result of normalizing the vector to `magnitude`. #[inline] pub fn normalize_to(&self, magnitude: T) -> Vec3 { - self.mul_t(magnitude / self.magnitude()) + self.mul_s(magnitude / self.magnitude()) } /// Returns the result of linarly interpolating the magnitude of the vector /// to the magnitude of `other` by the specified amount. #[inline] pub fn lerp(&self, other: &Vec3, amount: T) -> Vec3 { - 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`. #[inline] pub fn normalize_self(&mut self) { let rlen = self.magnitude().recip(); - self.mul_self_t(rlen); + self.mul_self_s(rlen); } /// Normalizes the vector to `magnitude`. #[inline] pub fn normalize_self_to(&mut self, magnitude: T) { 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 /// `other` by the specified amount. pub fn lerp_self(&mut self, other: &Vec3, 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); } } impl OrdVec> for Vec3 { #[inline] - pub fn lt_t(&self, value: T) -> Vec3 { + pub fn lt_s(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) < value, *self.index(1) < value, *self.index(2) < value) } #[inline] - pub fn le_t(&self, value: T) -> Vec3 { + pub fn le_s(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) <= value, *self.index(1) <= value, *self.index(2) <= value) } #[inline] - pub fn ge_t(&self, value: T) -> Vec3 { + pub fn ge_s(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) >= value, *self.index(1) >= value, *self.index(2) >= value) } #[inline] - pub fn gt_t(&self, value: T) -> Vec3 { + pub fn gt_s(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) > value, *self.index(1) > value, *self.index(2) > value) @@ -1155,14 +1155,14 @@ impl OrdVec> for Vec3 { } #[inline] - pub fn min_t(&self, value: T) -> Vec3 { + pub fn min_s(&self, value: T) -> Vec3 { Vec3::new(self.index(0).min(&value), self.index(1).min(&value), self.index(2).min(&value)) } #[inline] - pub fn max_t(&self, value: T) -> Vec3 { + pub fn max_s(&self, value: T) -> Vec3 { Vec3::new(self.index(0).max(&value), self.index(1).max(&value), self.index(2).max(&value)) @@ -1197,14 +1197,14 @@ impl OrdVec> for Vec3 { impl EqVec> for Vec3 { #[inline] - pub fn eq_t(&self, value: T) -> Vec3 { + pub fn eq_s(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) == value, *self.index(1) == value, *self.index(2) == value) } #[inline] - pub fn ne_t(&self, value: T) -> Vec3 { + pub fn ne_s(&self, value: T) -> Vec3 { Vec3::new(*self.index(0) != value, *self.index(1) != value, *self.index(2) != value) @@ -1289,8 +1289,8 @@ mod vec3_tests{ assert_eq!(-A, Vec3::new::(-1.0, -2.0, -3.0)); assert_eq!(A.neg(), Vec3::new::(-1.0, -2.0, -3.0)); - assert_eq!(A.mul_t(F1), Vec3::new::(1.5, 3.0, 4.5)); - assert_eq!(A.div_t(F2), Vec3::new::(2.0, 4.0, 6.0)); + assert_eq!(A.mul_s(F1), Vec3::new::(1.5, 3.0, 4.5)); + assert_eq!(A.div_s(F2), Vec3::new::(2.0, 4.0, 6.0)); assert_eq!(A.add_v(&B), Vec3::new::(5.0, 7.0, 9.0)); assert_eq!(A.sub_v(&B), Vec3::new::(-3.0, -3.0, -3.0)); @@ -1301,12 +1301,12 @@ mod vec3_tests{ assert_eq!(mut_a, -A); mut_a = A; - mut_a.mul_self_t(F1); - assert_eq!(mut_a, A.mul_t(F1)); + mut_a.mul_self_s(F1); + assert_eq!(mut_a, A.mul_s(F1)); mut_a = A; - mut_a.div_self_t(F2); - assert_eq!(mut_a, A.div_t(F2)); + mut_a.div_self_s(F2); + assert_eq!(mut_a, A.div_s(F2)); mut_a = A; mut_a.add_self_v(&B); @@ -1515,7 +1515,7 @@ impl Vec for Vec4 {} impl NumVec for Vec4 { /// Returns a new vector with `value` added to each component. #[inline] - pub fn add_t(&self, value: T) -> Vec4 { + pub fn add_s(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) + value, *self.index(1) + value, *self.index(2) + value, @@ -1524,7 +1524,7 @@ impl NumVec for Vec4 { /// Returns a new vector with `value` subtracted from each component. #[inline] - pub fn sub_t(&self, value: T) -> Vec4 { + pub fn sub_s(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) - value, *self.index(1) - value, *self.index(2) - value, @@ -1533,7 +1533,7 @@ impl NumVec for Vec4 { /// Returns the scalar multiplication of the vector with `value`. #[inline] - pub fn mul_t(&self, value: T) -> Vec4 { + pub fn mul_s(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) * value, *self.index(1) * value, *self.index(2) * value, @@ -1542,7 +1542,7 @@ impl NumVec for Vec4 { /// Returns a new vector with each component divided by `value`. #[inline] - pub fn div_t(&self, value: T) -> Vec4 { + pub fn div_s(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) / value, *self.index(1) / value, *self.index(2) / value, @@ -1551,7 +1551,7 @@ impl NumVec for Vec4 { /// Returns the remainder of each component divided by `value`. #[inline] - pub fn rem_t(&self, value: T) -> Vec4 { + pub fn rem_s(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) % value, *self.index(1) % value, *self.index(2) % value, @@ -1614,7 +1614,7 @@ impl NumVec for Vec4 { /// Adds `value` to each component of the vector. #[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(1) = *self.index(1) + value; *self.index_mut(2) = *self.index(2) + value; @@ -1623,7 +1623,7 @@ impl NumVec for Vec4 { /// Subtracts `value` from each component of the vector. #[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(1) = *self.index(1) - value; *self.index_mut(2) = *self.index(2) - value; @@ -1631,7 +1631,7 @@ impl NumVec for Vec4 { } #[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(1) = *self.index(1) * value; *self.index_mut(2) = *self.index(2) * value; @@ -1639,7 +1639,7 @@ impl NumVec for Vec4 { } #[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(1) = *self.index(1) / value; *self.index_mut(2) = *self.index(2) / value; @@ -1647,7 +1647,7 @@ impl NumVec for Vec4 { } #[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(1) = *self.index(1) % value; *self.index_mut(2) = *self.index(2) % value; @@ -1757,41 +1757,41 @@ impl FloatVec for Vec4 { /// Returns the result of normalizing the vector to `magnitude`. #[inline] pub fn normalize_to(&self, magnitude: T) -> Vec4 { - self.mul_t(magnitude / self.magnitude()) + self.mul_s(magnitude / self.magnitude()) } /// Returns the result of linarly interpolating the magnitude of the vector /// to the magnitude of `other` by the specified amount. #[inline] pub fn lerp(&self, other: &Vec4, amount: T) -> Vec4 { - 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`. #[inline] pub fn normalize_self(&mut self) { let rlen = self.magnitude().recip(); - self.mul_self_t(rlen); + self.mul_self_s(rlen); } /// Normalizes the vector to `magnitude`. #[inline] pub fn normalize_self_to(&mut self, magnitude: T) { 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 /// `other` by the specified amount. pub fn lerp_self(&mut self, other: &Vec4, 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); } } impl OrdVec> for Vec4 { #[inline] - pub fn lt_t(&self, value: T) -> Vec4 { + pub fn lt_s(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) < value, *self.index(1) < value, *self.index(2) < value, @@ -1799,7 +1799,7 @@ impl OrdVec> for Vec4 { } #[inline] - pub fn le_t(&self, value: T) -> Vec4 { + pub fn le_s(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) <= value, *self.index(1) <= value, *self.index(2) <= value, @@ -1807,7 +1807,7 @@ impl OrdVec> for Vec4 { } #[inline] - pub fn ge_t(&self, value: T) -> Vec4 { + pub fn ge_s(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) >= value, *self.index(1) >= value, *self.index(2) >= value, @@ -1815,7 +1815,7 @@ impl OrdVec> for Vec4 { } #[inline] - pub fn gt_t(&self, value: T) -> Vec4 { + pub fn gt_s(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) > value, *self.index(1) > value, *self.index(2) > value, @@ -1855,7 +1855,7 @@ impl OrdVec> for Vec4 { } #[inline] - pub fn min_t(&self, value: T) -> Vec4 { + pub fn min_s(&self, value: T) -> Vec4 { Vec4::new(self.index(0).min(&value), self.index(1).min(&value), self.index(2).min(&value), @@ -1863,7 +1863,7 @@ impl OrdVec> for Vec4 { } #[inline] - pub fn max_t(&self, value: T) -> Vec4 { + pub fn max_s(&self, value: T) -> Vec4 { Vec4::new(self.index(0).max(&value), self.index(1).max(&value), self.index(2).max(&value), @@ -1901,7 +1901,7 @@ impl OrdVec> for Vec4 { impl EqVec> for Vec4 { #[inline] - pub fn eq_t(&self, value: T) -> Vec4 { + pub fn eq_s(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) == value, *self.index(1) == value, *self.index(2) == value, @@ -1909,7 +1909,7 @@ impl EqVec> for Vec4 { } #[inline] - pub fn ne_t(&self, value: T) -> Vec4 { + pub fn ne_s(&self, value: T) -> Vec4 { Vec4::new(*self.index(0) != value, *self.index(1) != value, *self.index(2) != value, @@ -1988,8 +1988,8 @@ mod vec4_tests { assert_eq!(-A, Vec4::new::(-1.0, -2.0, -3.0, -4.0)); assert_eq!(A.neg(), Vec4::new::(-1.0, -2.0, -3.0, -4.0)); - assert_eq!(A.mul_t(F1), Vec4::new::(1.5, 3.0, 4.5, 6.0)); - assert_eq!(A.div_t(F2), Vec4::new::(2.0, 4.0, 6.0, 8.0)); + assert_eq!(A.mul_s(F1), Vec4::new::(1.5, 3.0, 4.5, 6.0)); + assert_eq!(A.div_s(F2), Vec4::new::(2.0, 4.0, 6.0, 8.0)); assert_eq!(A.add_v(&B), Vec4::new::(6.0, 8.0, 10.0, 12.0)); assert_eq!(A.sub_v(&B), Vec4::new::(-4.0, -4.0, -4.0, -4.0)); @@ -2002,12 +2002,12 @@ mod vec4_tests { assert_eq!(mut_a, -A); mut_a = A; - mut_a.mul_self_t(F1); - assert_eq!(mut_a, A.mul_t(F1)); + mut_a.mul_self_s(F1); + assert_eq!(mut_a, A.mul_s(F1)); mut_a = A; - mut_a.div_self_t(F2); - assert_eq!(mut_a, A.div_t(F2)); + mut_a.div_self_s(F2); + assert_eq!(mut_a, A.div_s(F2)); mut_a = A; mut_a.add_self_v(&B); diff --git a/src/transform/rotation.rs b/src/transform/rotation.rs index 041e30b..ca662d3 100644 --- a/src/transform/rotation.rs +++ b/src/transform/rotation.rs @@ -389,7 +389,7 @@ impl Rotation3 for AxisAngle { impl ToQuat for AxisAngle { pub fn to_quat(&self) -> Quat { 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())) } }