Added project_on to InnerSpace
This commit is contained in:
parent
b87401be28
commit
cea162df8c
1 changed files with 9 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue