Add Vector::angle_to

This commit is contained in:
Hanno Braun 2024-07-29 18:55:24 +02:00
parent 06baede8e7
commit c38ab65562

View File

@ -87,6 +87,11 @@ impl<const D: usize> Vector<D> {
self.to_na().normalize().into()
}
/// Compute the angle between this vector and another
pub fn angle_to(&self, other: &Self) -> Scalar {
(self.dot(other) / (self.magnitude() * other.magnitude())).acos()
}
/// Compute the dot product with another vector
pub fn dot(&self, other: &Self) -> Scalar {
self.to_na().dot(&other.to_na()).into()