Portability | portable (needs FFI) |
---|---|
Stability | provisional |
Maintainer | felipe.lessa@gmail.com |
Functionality used by various modules and routines for initialization and change of global variables.
- initChipmunk :: IO ()
- type CpFloat = Double
- infinity :: CpFloat
- type Time = CpFloat
- type Angle = CpFloat
- resetShapeCounter :: IO ()
- getContactPersistence :: IO Int32
- setContactPersistence :: Int32 -> IO ()
- getCollisionSlop :: IO CpFloat
- setCollisionSlop :: CpFloat -> IO ()
- getBiasCoef :: IO CpFloat
- setBiasCoef :: CpFloat -> IO ()
- getJointBiasCoef :: IO CpFloat
- setJointBiasCoef :: CpFloat -> IO ()
- data Vector = Vector !CpFloat !CpFloat
- type Position = Vector
- fromAngle :: Angle -> Vector
- len :: Vector -> CpFloat
- normalize :: Vector -> Vector
- scale :: Vector -> CpFloat -> Vector
- toAngle :: Vector -> Angle
- dot :: Vector -> Vector -> CpFloat
- cross :: Vector -> Vector -> CpFloat
- perp :: Vector -> Vector
- project :: Vector -> Vector -> Vector
- rotate :: Vector -> Vector -> Vector
- unrotate :: Vector -> Vector -> Vector
Initialization
Initilizes the Chipmunk library. This should be called once before using any functions of this library.
Basic data types
Type synonym used to hint that the argument or result represents an angle in radians.
Global variables
Chipmunk tries to maintein a very few number of global
variables to allow multiple Physics.Hipmunk.Space.Space
s
to be used simultaneously, however there are some.
Shape counter
The shape counter is a global counter used for creating unique hash identifiers to the shapes.
resetShapeCounter :: IO ()Source
resetShapeCounter
reset the shape counter to its default value.
This is used to add determinism to a simulation. As the ids
created with this counter may affect the order in which the
collisions happen, there may be very slight differences in
different simulations.
However, be careful as you should not use shapes created
before a call to resetCounter
with shapes created after
it as they may have the same id.
Contact persistence
This variable determines how long contacts should persist. It should be small as the cached contacts will only be close for a short time. (default is 3)
setContactPersistence :: Int32 -> IO ()Source
Collision slop
The collision slop is the amount that shapes are allowed to penetrate. Setting this to zero will work just fine, but using a small positive amount will help prevent oscillating contacts. (default is 0.1)
setCollisionSlop :: CpFloat -> IO ()Source
Bias coefficient
The amount of penetration to reduce in each step. Values should range from 0 to 1. Using large values will eliminate penetration in fewer steps, but can cause vibration. (default is 0.1)
setBiasCoef :: CpFloat -> IO ()Source
Joint bias coefficient
Similar to the bias coefficient, but for all joints. In the future, joints might have their own bias coefficient instead. (default is 0.1)
setJointBiasCoef :: CpFloat -> IO ()Source
Vectors
Type synonym used to hint that the argument or result represents a position.
fromAngle :: Angle -> VectorSource
Constructs an unitary vector pointing to the given angle (in radians).
toAngle :: Vector -> AngleSource
toAngle v
is the angle that v
has
with the vector Vector 1 0
(modulo 2*pi
).
perp :: Vector -> VectorSource
perp v
is a vector of same length as v
but perpendicular
to v
(i.e. toAngle (perp v) - toAngle v
equals pi/2
modulo 2*pi
).