shapes-0.1.0.0: physics engine and other tools for 2D shapes

Safe HaskellNone
LanguageHaskell2010

Physics.Transform

Description

Types for keeping track of local spaces (transformed relative to global space). Also, tools for creating and composing 2D transformations.

Synopsis

Documentation

type WorldTransform = SP M3x3 M3x3 Source #

A pair of transformation matrices to and from world space, respectively. See transform and untransform.

The transformation matrices are multiplied with (2D affine) column vectors.

toTransform Source #

Arguments

:: V2

Translation

-> Double#

Rotation

-> WorldTransform 

Create a WorldTransform with a given translation and rotation.

Applying the resulting WorldTransform in the forward direction moves the origin to the first argument (:: V2), and rotates by the second argument (:: Double#).

Applying the result in the reverse direction will revert the transformation.

scaleTransform Source #

Arguments

:: V2

Scale

-> WorldTransform 

Create a WorldTransform with a given scale.

rotateTransform Source #

Arguments

:: Double#

Rotation

-> WorldTransform 

Create a WorldTransform with a given rotation.

translateTransform Source #

Arguments

:: V2

Translation

-> WorldTransform 

Create a WorldTransform with a given translation.

idTransform :: WorldTransform Source #

Identity WorldTransform does not alter the space.

joinTransforms Source #

Arguments

:: WorldTransform

The outer transform - applied last

-> WorldTransform

The inner transform - applied first

-> WorldTransform

The composite transform

Sequence two WorldTransforms to produce a third.

joinTransforms' Source #

Arguments

:: [WorldTransform]

Transforms in order from outermost to innermost

-> WorldTransform

The composite transform

Sequence a list of WorldTransforms.

invertTransform :: WorldTransform -> WorldTransform Source #

Reverse the direction of a WorldTransform. Simply swaps the two transformation matrices.

data WorldT a Source #

Constructors

WorldT !a 

class WorldTransformable t where Source #

Minimal complete definition

transform, untransform

Methods

transform :: WorldTransform -> t -> t Source #

Apply WorldTransform in the forward direction (local space to world space).

untransform :: WorldTransform -> t -> t Source #

Apply WorldTransform in the reverse direction (world space to local space).

wExtract :: LocalT t -> WorldT t Source #

wExtract_ :: LocalT t -> t Source #

wInject :: WorldTransform -> WorldT t -> LocalT t Source #

wInject_ :: WorldTransform -> t -> t Source #

Instances

WorldTransformable V2 Source # 
WorldTransformable P2 Source # 
WorldTransformable b => WorldTransformable [b] Source # 

Methods

transform :: WorldTransform -> [b] -> [b] Source #

untransform :: WorldTransform -> [b] -> [b] Source #

wExtract :: LocalT [b] -> WorldT [b] Source #

wExtract_ :: LocalT [b] -> [b] Source #

wInject :: WorldTransform -> WorldT [b] -> LocalT [b] Source #

wInject_ :: WorldTransform -> [b] -> [b] Source #

WorldTransformable b => WorldTransformable (Maybe b) Source # 
WorldTransformable t => WorldTransformable (WorldT t) Source # 
WorldTransformable (LocalT b) Source # 
WorldTransformable b => WorldTransformable (b, b) Source # 

Methods

transform :: WorldTransform -> (b, b) -> (b, b) Source #

untransform :: WorldTransform -> (b, b) -> (b, b) Source #

wExtract :: LocalT (b, b) -> WorldT (b, b) Source #

wExtract_ :: LocalT (b, b) -> (b, b) Source #

wInject :: WorldTransform -> WorldT (b, b) -> LocalT (b, b) Source #

wInject_ :: WorldTransform -> (b, b) -> (b, b) Source #

WorldTransformable w => WorldTransformable (WaL w l) Source # 

Methods

transform :: WorldTransform -> WaL w l -> WaL w l Source #

untransform :: WorldTransform -> WaL w l -> WaL w l Source #

wExtract :: LocalT (WaL w l) -> WorldT (WaL w l) Source #

wExtract_ :: LocalT (WaL w l) -> WaL w l Source #

wInject :: WorldTransform -> WorldT (WaL w l) -> LocalT (WaL w l) Source #

wInject_ :: WorldTransform -> WaL w l -> WaL w l Source #

data WaL w l Source #

Constructors

WaL 

Fields

Instances

(Show l, Show w) => Show (WaL w l) Source # 

Methods

showsPrec :: Int -> WaL w l -> ShowS #

show :: WaL w l -> String #

showList :: [WaL w l] -> ShowS #

WorldTransformable w => WorldTransformable (WaL w l) Source # 

Methods

transform :: WorldTransform -> WaL w l -> WaL w l Source #

untransform :: WorldTransform -> WaL w l -> WaL w l Source #

wExtract :: LocalT (WaL w l) -> WorldT (WaL w l) Source #

wExtract_ :: LocalT (WaL w l) -> WaL w l Source #

wInject :: WorldTransform -> WorldT (WaL w l) -> LocalT (WaL w l) Source #

wInject_ :: WorldTransform -> WaL w l -> WaL w l Source #

type WaL' t = WaL t t Source #

wfmap :: Functor t => (a -> t b) -> WorldT a -> t (WorldT b) Source #

wflip :: Functor t => WorldT (t a) -> t (WorldT a) Source #

wmap :: (a -> b) -> WorldT a -> WorldT b Source #

wlift2 :: (a -> b -> c) -> WorldT a -> WorldT b -> WorldT c Source #

wlift2_ :: (a -> b -> c) -> WorldT a -> WorldT b -> c Source #

wap :: WorldT (a -> b) -> WorldT a -> WorldT b Source #

wlap :: WorldTransformable a => WorldT (a -> b) -> LocalT a -> WorldT b Source #

lwap :: WorldTransformable a => LocalT (a -> b) -> WorldT a -> LocalT b Source #

lap :: WorldTransformable a => LocalT (a -> b) -> LocalT a -> LocalT b Source #

lmap :: (a -> b) -> LocalT a -> LocalT b Source #

lfmap :: Functor t => (a -> t b) -> LocalT a -> t (LocalT b) Source #

lunsafe_ :: (a -> b) -> LocalT a -> b Source #

wlens :: Functor f => (a -> f a) -> WorldT a -> f (WorldT a) Source #