Safe Haskell | None |
---|---|
Language | Haskell2010 |
Types for keeping track of local spaces (transformed relative to global space). Also, tools for creating and composing 2D transformations.
- type WorldTransform = SP M3x3 M3x3
- toTransform :: V2 -> Double# -> WorldTransform
- scaleTransform :: V2 -> WorldTransform
- rotateTransform :: Double# -> WorldTransform
- translateTransform :: V2 -> WorldTransform
- idTransform :: WorldTransform
- joinTransforms :: WorldTransform -> WorldTransform -> WorldTransform
- joinTransforms' :: [WorldTransform] -> WorldTransform
- invertTransform :: WorldTransform -> WorldTransform
- data LocalT b = LocalT !WorldTransform !b
- type LV2 = LocalT V2
- type LP2 = LocalT P2
- data WorldT a = WorldT !a
- type WV2 = WorldT V2
- type WP2 = WorldT P2
- iExtract :: WorldT a -> a
- iInject :: a -> WorldT a
- iInject_ :: b -> LocalT b
- class WorldTransformable t where
- data WaL w l = WaL {}
- type WaL' t = WaL t t
- wfmap :: Functor t => (a -> t b) -> WorldT a -> t (WorldT b)
- wflip :: Functor t => WorldT (t a) -> t (WorldT a)
- wmap :: (a -> b) -> WorldT a -> WorldT b
- wlift2 :: (a -> b -> c) -> WorldT a -> WorldT b -> WorldT c
- wlift2_ :: (a -> b -> c) -> WorldT a -> WorldT b -> c
- wap :: WorldT (a -> b) -> WorldT a -> WorldT b
- wlap :: WorldTransformable a => WorldT (a -> b) -> LocalT a -> WorldT b
- lwap :: WorldTransformable a => LocalT (a -> b) -> WorldT a -> LocalT b
- lap :: WorldTransformable a => LocalT (a -> b) -> LocalT a -> LocalT b
- lmap :: (a -> b) -> LocalT a -> LocalT b
- lfmap :: Functor t => (a -> t b) -> LocalT a -> t (LocalT b)
- lunsafe_ :: (a -> b) -> LocalT a -> b
- wlens :: Functor f => (a -> f a) -> WorldT a -> f (WorldT a)
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.
:: 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.
:: Double# | Rotation |
-> WorldTransform |
Create a WorldTransform
with a given rotation.
:: V2 | Translation |
-> WorldTransform |
Create a WorldTransform
with a given translation.
idTransform :: WorldTransform Source #
Identity WorldTransform
does not alter the space.
:: WorldTransform | The outer transform - applied last |
-> WorldTransform | The inner transform - applied first |
-> WorldTransform | The composite transform |
Sequence two WorldTransform
s to produce a third.
:: [WorldTransform] | Transforms in order from outermost to innermost |
-> WorldTransform | The composite transform |
Sequence a list of WorldTransform
s.
invertTransform :: WorldTransform -> WorldTransform Source #
Reverse the direction of a WorldTransform
.
Simply swaps the two transformation matrices.
LocalT !WorldTransform !b |
WorldT !a |
class WorldTransformable t where Source #
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 #
WorldTransformable V2 Source # | |
WorldTransformable P2 Source # | |
WorldTransformable b => WorldTransformable [b] Source # | |
WorldTransformable b => WorldTransformable (Maybe b) Source # | |
WorldTransformable t => WorldTransformable (WorldT t) Source # | |
WorldTransformable (LocalT b) Source # | |
WorldTransformable b => WorldTransformable (b, b) Source # | |
WorldTransformable w => WorldTransformable (WaL w l) Source # | |