diff --git a/crates/fj-math/src/vector.rs b/crates/fj-math/src/vector.rs index 4e6c45273..5c08f6bd4 100644 --- a/crates/fj-math/src/vector.rs +++ b/crates/fj-math/src/vector.rs @@ -87,6 +87,11 @@ impl Vector { 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()