geom2d-0.1.2.0: Geom2d/Rotation.hs
-- | This module contains a type class that can be used to modell
-- data, that can be rotated by a given angle.
module Geom2d.Rotation
where
-- | Modells data that has an angle and can be rotated.
class Rotation p where
-- | An object can return the orientation in space. If the object
-- returns its orientation it should hold the following law:
--
-- prop> 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`
--
-- prop> fromMaybe True (fmap (\a -> a >= (- pi) && a <= pi) (angle x))
--
-- The default implementation is
--
-- @
-- angle _ = Nothing
-- @
angle :: (Floating a, RealFloat a, Ord a) => p a -> Maybe a
angle _ = Nothing
-- | Should rotate an object by a given angle.
rotate :: (Floating a) => a -> p a -> p a