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

Safe HaskellNone
LanguageHaskell2010

Physics.World.Class

Description

Classes for data structures that can behave like a "world" of physical objects.

Synopsis

Documentation

class Physical p where Source #

Class for objects with physical properties.

Minimal complete definition

woPhys

Methods

woPhys :: Functor f => (PhysicalObj -> f PhysicalObj) -> p -> f p Source #

Lens for the embedded PhysicalObj

Instances

class Physical p => Contactable p where Source #

Class for objects that can be in contact with each other.

Minimal complete definition

woMu, woShape, woMuShape

Methods

woMu :: Functor f => (Double -> f Double) -> p -> f p Source #

Lens for embedded coefficient of friction "mu"

woShape :: Functor f => (Shape -> f Shape) -> p -> f p Source #

Lens for embedded contact shape

woMuShape :: Functor f => ((Double, Shape) -> f (Double, Shape)) -> p -> f p Source #

Lens for embedded pair of (coefficient of friction, contact shape)

Instances

Contactable (WorldObj a) Source # 

Methods

woMu :: Functor f => (Double -> f Double) -> WorldObj a -> f (WorldObj a) Source #

woShape :: Functor f => (Shape -> f Shape) -> WorldObj a -> f (WorldObj a) Source #

woMuShape :: Functor f => ((Double, Shape) -> f (Double, Shape)) -> WorldObj a -> f (WorldObj a) Source #

class (Ord k, Contactable o) => PhysicsWorld k w o | w -> k o where Source #

Class for worlds (:: w) inhabited by physical objects (:: o) each uniquely identified by a key (:: k)

Minimal complete definition

wKeys, wObj, wPair, wObjs

Methods

wKeys :: w -> [k] Source #

Keys of all the world's inhabitants

wObj :: k -> Traversal' w o Source #

Traversal of inhabitants with a given key

wPair :: (k, k) -> Traversal' w (o, o) Source #

Traversal' of pairs of inhabitants with a given pair of keys

wObjs :: IndexedTraversal' k w o Source #

IndexedTraversal' of all inhabitants

Instances

wAdvance Source #

Arguments

:: PhysicsWorld k w o 
=> Double

Time delta

-> w 
-> w 

Advance the physical state of the world by a given time delta using each inhabitant's current velocity.

woUpdateShape :: Contactable o => o -> o Source #

Update the shape of an object to match its current physical state.

By keeping all shapes in world space, we ensure that each shape only needs to be transformed once per frame.

type External = Double -> PhysicalObj -> PhysicalObj Source #

An External is a non-constraint effect (e.g. gravity) on physical objects.

wApplyExternals :: PhysicsWorld k w o => [External] -> Double -> w -> w Source #

Apply External effects to the objects in a world.

This happens each frame before constraints are created and solved.