Remove more *_self methods from Vector trait

This commit is contained in:
Brendan Zabarauskas 2015-12-13 00:24:24 +11:00
parent 534ba55d3e
commit 43634f0b49
2 changed files with 1 additions and 34 deletions

View file

@ -324,13 +324,6 @@ impl<S: BaseNum> Vector3<S> {
(self.x * other.y) - (self.y * other.x))
}
/// Calculates the cross product of the vector and `other`, then stores the
/// result in `self`.
#[inline]
pub fn cross_self(&mut self, other: Vector3<S>) {
*self = self.cross(other)
}
/// Create a `Vector4`, using the `x`, `y` and `z` values from this vector, and the
/// provided `w`.
#[inline]
@ -414,7 +407,7 @@ pub trait EuclideanVector: Vector + Sized where
/// The norm of the vector.
#[inline]
fn length(self) -> Self::Scalar {
// Not sure why these annotations are needed
// FIXME: Not sure why this annotation is needed
<<Self as Vector>::Scalar as ::rust_num::Float>::sqrt(self.dot(self))
}
@ -443,28 +436,6 @@ pub trait EuclideanVector: Vector + Sized where
fn lerp(self, other: Self, amount: Self::Scalar) -> Self {
self + ((other - self) * amount)
}
/// Normalises the vector to a length of `1`.
#[inline]
fn normalize_self(&mut self) {
// Not sure why these annotations are needed
let rlen = <<Self as Vector>::Scalar as ::rust_num::Float>::recip(self.length());
*self = *self * rlen;
}
/// Normalizes the vector to `length`.
#[inline]
fn normalize_self_to(&mut self, length: Self::Scalar) {
let n = length / self.length();
*self = *self * n;
}
/// Linearly interpolates the length of the vector towards the length of
/// `other` by the specified amount.
fn lerp_self(&mut self, other: Self, amount: Self::Scalar) {
let v = (other - *self) * amount;
*self = *self * v;
}
}
impl<S: BaseFloat> EuclideanVector for Vector2<S> {

View file

@ -90,10 +90,6 @@ fn test_cross() {
let b = Vector3::new(4isize, 5isize, 6isize);
let r = Vector3::new(-3isize, 6isize, -3isize);
assert_eq!(a.cross(b), r);
let mut a = a;
a.cross_self(b);
assert_eq!(a, r);
}
#[test]