Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module contains a type class that can be used to modell data, that can be rotated by a given angle.
Documentation
Modells data that has an angle and can be rotated.
angle :: (Floating a, RealFloat a, Ord a) => p a -> Maybe a Source
An object can return the orientation in space. If the object returns its orientation it should hold the following law:
fromMaybe True $ (==) <$> angle (r `rotate` x) <*> ((subtract pi).((`mod'` (2*pi)).(+pi).(+r)) <$> angle x)
Also angle should never return a value bigger than pi
and
smaller than `- pi`
fromMaybe True (fmap (\a -> a >= (- pi) && a <= pi) (angle x))
The default implementation is
angle _ = Nothing
rotate :: Floating a => a -> p a -> p a Source
Should rotate an object by a given angle.