3      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~portable (needs FFI) provisionalfelipe.lessa@gmail.com7Initilizes the Chipmunk library. This should be called 4 once before using any functions of this library. infinity# may be used to create bodies with  an infinite mass. 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. 9However, 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. 3Constructs an unitary vector pointing to the given  angle (in radians). The length of a vector. 7Normalizes the vector (i.e. divides it by its length). 6Scales the components of a vector by the same amount.  toAngle v is the angle that v has  with the vector  Vector 1 0 (modulo 2*pi). v1 `dot` v2& computes the familiar dot operation. v1 `cross` v2( computes the familiar cross operation. 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). v1 `project` v2 is the vector projection of v1 onto v2. v1 `rotate` v2 uses complex multiplication  to rotate (and scale) v1 by v2. The inverse operation of rotate , such that  unrotate (rotate v1 v2) v2 equals v1. 6Type synonym used to hint that the argument or result  represents a position. /A two-dimensional vector. It is an instance of   however the operations  and '(*)' are not  supported. 6Type synonym used to hint that the argument or result # represents an angle in radians. 6Type synonym used to hint that the argument or result  represents time. 5The floating point type used internally in Chipmunk.    portable (needs FFI) provisionalfelipe.lessa@gmail.com A ) contains information about a collision.  It is passed to Physics.Hipmunk.Space.Full.  The fields ! and " do not have any meaningfull  value until Physics.Hipmunk.Space.step has returned 6 (i.e. during a call to a callback this information 9 contains garbage), and by extension you can only know  the impulse sum after step returns as well.  IMPORTANT:* You may maintain a reference to an array  of Contact0s that was passed to a callback to do any other  processing later. However, a new call to step/ will ! invalidate any of those arrays/! Be careful. "Position of the collision in world's coordinates. Normal of the collision. 'Penetration distance of the collision. !+Normal component of final impulse applied.  (Valid only after step finishes.) "/Tangential component of final impulse applied.  (Valid only after step finishes.) #7A space is where the simulation really occurs. You add 9 bodies, shapes and joints to a space and then step it  to update it as whole. $6A joint represents a constrain between two bodies. Don't 8 forget to add the bodies and the joint to the space. %#A collision shape is attached to a Body to define its 5 shape. Multiple shapes may be attached, including ) overlapping ones (shapes of a body don't generate collisions  with each other).  Note that to have any effect, a % must also be  added to a #&, even if the body was already added. &@A rigid body representing the physical properties of an object, @ but without a shape. It may help to think as a particle that  is able to rotate.  !"#$%&&%$# !"portable (needs FFI) provisionalfelipe.lessa@gmail.com 'newBody mass inertia creates a new & with ) the given mass and moment of inertia. It is recommended to call / afterwards. /5Note that using this function to change the position 4 on every step is not recommended as it may leave  the velocity out of sync. 8slew b newpos dt changes the body b' s velocity  so that it reaches newpos in dt time. /It is usually used to change the position of a 4 static body in the world. In that case, remember - to reset the velocity to zero afterwards! 9#updateVelocity b gravity damping dt redefines body b's 7 linear and angular velocity to account for the force/torque 9 being applied to it, the gravity and a damping factor  during dt time using Euler integration. 7Note that this function only needs to be called if you ' are not adding the body to a space. :updatePosition b dt" redefines the body position like  9 (and it also shouldn't be called if you % are adding this body to a space). ; resetForces b) redefines as zero all forces and torque  acting on body b. <applyForce b f r applies to the body b the force  f with offset r%, both vectors in world coordinates. / This is the most stable way to change a body' s velocity. 7Note that the force is accumulated in the body, so you  may need to call =. =applyOnlyForce b f r applies a force like <,  but calling ; before. Note that using this > function is preferable as it is optimized over this common  case. >applyImpulse b j r applies to the body b the impulse  j with offset r%, both vectors in world coordinates. ?*dampedSpring (b1,a1) (b2,a2) rlen k dmp dt applies a damped  spring force between bodies b1 and b2 at anchors  a1 and a2, respectively. k is the spring constant  (force/ distance), rlen# is the rest length of the spring,  dmp is the damping constant (force/velocity), and dt > is the time step to apply the force over. Both anchors are  in body coordinates. ;Note: not solving the damping forces in the impulse solver < causes problems with large damping values. This function A will eventually be replaced by a new constraint (joint) type. @ For a vector p in body b's coordinates,  localToWorld b p" returns the corresponding vector  in world coordinates. A For a vector p in world coordinates,  worldToLocal b p" returns the corresponding vector  in body b's coordinates. "&'()*+,-./0123456789:;<=>?@ABCDEFG"&'G()F*+./E01D23,-C45B6789:;<=>?@Aportable (needs FFI) provisionalfelipe.lessa@gmail.comHnewShape b type off! creates a new shape attached to  body b at offset off. Note that you have to , add the shape to a space otherwise it won' t generate  collisions. I getBody s+ is the body that this shape is associated  to. Useful especially in Physics.Hipmunk.Space.Callback. VmomentForCircle m (ri,ro) off is the moment of inertia  of a circle of m mass, inner radius of ri, outer radius  of ro and at an offset off from the center of the body. WmomentForPoly m verts off is the moment of inertia of a  polygon of m mass, at offset off from the center of  the body and comprised of verts vertices. This is similar  to  shapePoly- (and the same restrictions for the vertices  apply as well). Internal. For l = [x1,x2,...,xn],  pairs f l is  [f x1 x2, f x2 x3, ...,f xn x1]. XshapeQuery shape p returns True iff the point in  position p (in world's coordinates) lies within  the shape shape. Y8The epsilon used in the algorithms below when necessary  to compare floats for "equality". Z"Equality" under Y . That is, a .==. b  if  abs (a - b) < = epsilon. [O(n). isClockwise verts is True iff verts form  a clockwise polygon. \isLeft (p1,p2) vert is  LT if vert' is at the left of the line defined by (p1,p2).  EQ if vert is at the line (p1,p2).  GT otherwise. ]O(n). isConvex verts is True iff vers form a convex  polygon. ^O(1). intersects seg1 seg2 is the intersection between  the two segments seg1 and seg2. See b. _O(n). polyReduce delta verts removes from verts all  points that have less than delta distance ( in relation to the one preceding it. 1Note that a very small polygon may be completely "eaten" $ if all its vertices are within a delta radius from the  first. `O(n). polyCenter verts is the position in the center  of the polygon formed by verts. a O(n log n). convexHull verts is the convex hull of the  polygon defined by verts. The vertices of the convex 5 hulls are given in clockwise winding. The polygon  doesn't have to be simple. #Implemented using Graham scan, see   1http://cgm.cs.mcgill.ca/~beezer/cs507/3coins.html. 2Internal. Works like minimum but also returns the : list without it. The order of the list may be changed.  We have "fst (takeMinimum xs) == minimum xs and  .sort (uncurry (:) $ takeMinimum xs) == sort xs b.A possible intersection between two segments. fA line segment. g4The surface velocity of the shape. Useful to create 5 conveyor belts and players that move around. This 5 value is only used when calculating friction, not  collision. (default is zero) h0The friction coefficient of the shape according # to Coulumb friction model (i.e. 0.0 is frictionless,  iron on iron is around 1.0, and it could be greater  then 1.0). 5The amount of friction applied during a collision is 6 determined by multiplying the friction coefficient % of both shapes. (default is zero) i)The elasticity of the shape is such that 0.0 gives no bounce  while 1.0 give a "perfect" bounce. Note that due to  inaccuracies using 1.0 or greater is not recommended. 7The amount of elasticity applied during a collision is < calculated by multiplying the elasticity of both shapes.  (default is zero)  IMPORTANT:+ by default no elastic iterations are done  when the space Physics.Hipmunk.Space.steps. This means 6 that all shapes react as they had zero elasticity. 5 So, if you want some elasticity, remember to call  *Physics.Hipmunk.Space.setElasticIterations to something  greater than zero, maybe 10. jALayers are similar to groups, but use a bitmask. For a collision @ to occur, two shapes must have at least one layer in common.  In other words, layer1 .&. layer2 should be non-zero.  (default is 0xFFFF) 9Note that although this type may have more than 32 bits, > for portability you should only rely on the lower 32 bits. k8Groups are used to filter collisions between shapes. If 5 the group is zero, then it imposes no restriction = to the collisions. However, if the group is non-zero then < the shape will not collide with other shapes in the same % non-zero group. (default is zero) 9This is primarely used to create multi-body, multi-shape @ objects such as ragdolls. It may be thought as a lightweight 7 alternative to creating a callback that filters the  collisions. l8The collision type is used to determine which collision  Physics.Hipmunk.Space.Callback will be called. Its  actual value doesn'$t have a meaning for Chipmunk other < than the correspondence between shapes and the collision - pair functions you add. (default is zero) m5There are three types of shapes that can be attached  to bodies: /%HIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu/%mnopqrstuHlJKkLMjNOiPQhRSgTUIVWXfbcdeYZ\[]^_`aportable (needs FFI) provisionalfelipe.lessa@gmail.comvnewJoint b1 b2 type connects the two bodies b1 and b2 8 with a joint of the given type. Note that you should  add the $ to a space. w9There are currently four types of joints. When appending ; a number to a property, we hint that it refer to one of 2 the bodies that the joint is contraining (e.g. anchor2 ; is the position of the anchor on the second body in its  coordinates). $vwxyz{|}~$wxyz{|}~vportable (needs FFI) provisionalfelipe.lessa@gmail.comCreates a new, empty space. : Some of the memory resources associated with the space " must be manually freed through  when the  # is no longer necessary.  freeSpace sp% frees some memory resources that can't 3 be automatically deallocated in a portable way.  The space sp! then becomes invalid and should  not be used (passing sp to any other function,  including ", results in undefined behavior). 4Strict version of modifyIORef (otherwise the thunks , will keep referencing removed entities). 0Rehashes the shapes in the static spatial hash. 5 You only need to call this if you move one of the  static shapes. spaceQuery sp query pos cb will call cb for every  shape that  Contains point pos (in world's coordinates).  Is in the hash selected by query (see ). :The order in which the callback is called is unspecified. 9 However it is guaranteed that it will be called once, 9 and only once, for each of the shapes described above  (and never for those who aren't). spaceQueryList sp query pos acts like  but  returns a list of %!s instead of calling a callback. ( This is just a convenience function.  step sp dt will update the space sp for a dt time  step. (It is highly recommended to use a fixed dt to increase ; the efficiency of contact persistence. Some tips may be  found in  4http://www.gaffer.org/game-physics/fix-your-timestep. Internal. Constructs a  from a , & returning also the contents of the data pointer. Internal. Retrive a % from a  and a #. /Defines a new default collision pair function. / This callback is called whenever two shapes a  and b& collide such that no other collision  pair function was defined to a's and b's # collision types. The default is  Constant True. addCallback sp (cta,ctb) f defines f as the callback 4 to be called whenever a collision occurs between  a shape of collision type cta and another of  collision type ctb& (and vice versa). Any other callback  already registered to handle  (cta,ctb) will be removed. Note that you should not add callbacks to both  combinations of  (cta,ctb) and  (ctb,cta). A good rule  of thumb is to always use cta <= ctb, although this  is not necessary. removeCallback sp (cta,ctb) removes any callbacks that  were registered to handle  (cta,ctb) (see ). 7 Any collisions that would be handled by the removed 4 callback will be handled by the default one (see  ). Note that you should always use the same order that  was passed to . In other words, after  addCallback sp (cta,ctb) f you should use  removeCallback sp (cta,ctb), and never  removeCallback sp (ctb,cta). 8Although pointless, it is harmless to remove a callback  that was not added. 7Sums the impulses applied to the given contact points.  " sums only the normal components. - This function should be called only after   returns. 7Sums the impulses applied to the given contact points. @ This function sums both the normal and tangential components # and should be called only after  returns. -Internal. Type of callback used by Chipmunk. A ! function can be of three types:  A . callback has access to all parameters passed < by Chipmunk, but it is common not to need all of them.  The two colliding %s are passed as arguments with  a 2 array and a normal coefficient (this coefficient ) should be multiplied to the contacts' normals as 9 Chipmunk may have reversed the argument order). See   for more information.  A  callback can' t access the  information, + but incurs a lower overhead per call.  A 2 callback always accepts or reject the collision.  For example, a Constant False will never accept any  collision.  Although  and  can be implemented  in terms of , they'%re optimized to incur less overhead. , So try to use the simplest callback type  (e.g. Constant False instead of Basic (_ _ -> return False)). /You may query the static hash, the active hash  or both. 1The time stamp of the simulation, increased in 1  every time  is called. 5The amount of viscous damping applied to the system.  (default is 1) 2The gravity applied to the system. (default is 0) BThe number of elastic iterations to use when solving constraints.  (default is 0). :The number of iterations to use when solving constraints.  (default is 10). A  is a % container that, when added  to a space via , is added to the static  list of shapes. 7A static shape is one assumed not to move. If you move 4 a static shape after adding it, then you need to . 8You should not add the same shape as active and static, 5 nor should you add as active and try to remove as  static or vice versa. /Type class implemented by entities that can be  added to a space. Add an entity to a #. Don't add the same  entity twice to a space. Remove an entity from a #. Don' t remove  an entity that wasn't add. 1 !"#1# !" portable (needs FFI) provisionalfelipe.lessa@gmail.com  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~     !!"#$%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Hipmunk-0.2Physics.Hipmunk.CommonPhysics.Hipmunk.SpacePhysics.Hipmunk.JointPhysics.Hipmunk.ShapePhysics.Hipmunk.BodybaseGHC.NumPhysics.Hipmunk.InternalPhysics.Hipmunk initChipmunkinfinityresetShapeCountergetContactPersistencesetContactPersistencegetCollisionSlopsetCollisionSlop getBiasCoef setBiasCoefgetJointBiasCoefsetJointBiasCoef fromAnglelen normalizescaletoAngledotcrossperpprojectrotateunrotatePositionVectorAngleTimeCpFloatContactctPosctNormalctDistctJnAccctJtAccSpaceJointShapeBodynewBodygetMasssetMass getMoment setMomentgetAnglesetAngle getPosition setPosition getVelocity setVelocitygetForcesetForce getAngVel setAngVel getTorque setTorqueslewupdateVelocityupdatePosition resetForces applyForceapplyOnlyForce applyImpulse dampedSpring localToWorld worldToLocalTorqueAngVelForceVelocityMomentMassnewShapegetBodygetCollisionTypesetCollisionTypegetGroupsetGroup getLayers setLayers getElasticity setElasticity getFriction setFriction getSurfaceVel setSurfaceVelmomentForCircle momentForPoly shapeQueryepsilon.==. isClockwiseisLeftisConvex intersects polyReduce polyCenter convexHull IntersectionIntSegmtIntPoint IntNowhereSegment SurfaceVelFriction ElasticityLayersGroup CollisionType ShapeTypePolygonvertices LineSegmentstartend thicknessCircleradiusnewJoint JointTypeGroovegroove1pivot2PivotpivotSlideminDistmaxDistPinanchor1anchor2newSpace freeSpace getIterations setIterationsgetElasticIterationssetElasticIterations getGravity setGravity getDamping setDamping getTimeStampresizeStaticHashresizeActiveHash rehashStatic spaceQueryspaceQueryListstepsetDefaultCallback addCallbackremoveCallback sumImpulsessumImpulsesWithFrictionCallbackConstantBasicFull QueryTypeBoth StaticHash ActiveHash TimeStampDampingGravityElasticIterations Iterations StaticShapeStaticunStaticEntityspaceAdd spaceRemoveNumsignumunBunSunJunP ContactPtrSpacePtrPJointPtrJShapePtrSBodyPtrB VectorPtrpairs takeMinimum modifyIORef'adaptChipmunkCB ChipmunkCB retriveShape