-- |module Diagrams.Test.Direction whereimport Diagrams.Directionimport Diagrams.Preludeimport Instancesimport Test.Tastyimport Test.Tasty.QuickChecktests :: TestTreetests = testGroup "Direction" [ testProperty "Length does not effect from direction" $ \(Positive f) (NonZero v) -> fromDirection(dir ((v :: V2 Double) ^* (f+0.001))) =~ fromDirection(dir v) , testProperty "HasTheta subtraction yeilds same result as anglebetween" $ (anglebetsub) , testProperty "anglebetweenDirs is commutative" $ \a b -> angleBetweenDirs (a :: Direction V2 Double) b =~ angleBetweenDirs b a , testProperty "fromdirection does not effect angleBetweenDirs" $ \a b -> angleBetween (fromDirection (a :: Direction V2 Double)) (fromDirection b) =~ angleBetweenDirs a b ]if' :: Bool -> a -> a -> aif' True x _ = xif' False _ y = yanglebetsub :: Direction V2 Double -> Direction V2 Double -> Boolanglebetsub a b = (if' (abs (a ^. _theta^.rad - b ^. _theta^.rad) < pi) (abs ((a ^. _theta ^-^ b ^. _theta)^.rad)) (2*pi - abs (a ^. _theta^.rad - b ^. _theta^.rad) ) =~ angleBetweenDirs a b ^.rad)