geom2d-0.1.3.1: package for geometry in euklidean 2d space

Safe HaskellSafe
LanguageHaskell2010

Geom2d.Rotation

Description

This module contains a type class that can be used to modell data, that can be rotated by a given angle.

Synopsis

Documentation

class Rotation p where Source

Modells data that has an angle and can be rotated.

Minimal complete definition

rotate

Methods

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.