Tweak movement

This commit is contained in:
jgk
2021-06-09 15:27:47 +02:00
parent 3371e2ae79
commit 8ec1ef62fb
4 changed files with 24 additions and 19 deletions
+7 -5
View File
@@ -72,11 +72,13 @@ normalizeV p = (1 / magV p) *.* p
{- | Angle between two vectors. Always positive. -}
angleVV :: Point2 -> Point2 -> Float
{-# INLINE angleVV #-}
angleVV a b =
let ma = magV a
mb = magV b
d = a `dotV` b
in acos $ d / (ma * mb)
angleVV a b
| a == b = 0
| otherwise =
let ma = magV a
mb = magV b
d = a `dotV` b
in acos $ d / (ma * mb)
{- | Safe version of 'angleVV' that returns 0 if either vector is null. -}
safeAngleVV :: Point2 -> Point2 -> Float
{-# INLINE safeAngleVV #-}