diff --git a/geometry.go b/geometry.go index a98b78c..dbb5bc4 100644 --- a/geometry.go +++ b/geometry.go @@ -169,6 +169,12 @@ func (u Vec) Normal() Vec { return Vec{-u.Y, u.X} } +// Returns angle between two vectors +func (u Vec) AngleTo(v Vec) { + u, v = u.Unit(), v.Unit() + return math.Acos(u.Dot(v)) +} + // Dot returns the dot product of vectors u and v. func (u Vec) Dot(v Vec) float64 { return u.X*v.X + u.Y*v.Y