Added project_on to InnerSpace

This commit is contained in:
Matthew Plant 2017-06-16 11:52:51 -07:00
parent b87401be28
commit cea162df8c

View file

@ -246,6 +246,15 @@ pub trait InnerSpace: VectorSpace where
fn lerp(self, other: Self, amount: Self::Scalar) -> Self {
self + ((other - self) * amount)
}
/// Returns the
/// [vector projection](https://en.wikipedia.org/wiki/Vector_projection)
/// of the current inner space projected onto the supplied argument.
#[inline]
#[must_use]
fn project_on(self, other: Self) -> Self {
other * (self.dot(other) / other.magnitude2())
}
}
/// Points in a [Euclidean space](https://en.wikipedia.org/wiki/Euclidean_space)