BaH.Chipmunk: Globals Functions Types Modinfo Source  

Chipmunk 2D Physics

Globals Summary

CPVZero

Functions Summary

DampedSpring Apply a spring force between bodies a and b at anchors anchor1 and anchor2 respectively.
InitChipmunk Initializes the physics engine.
MomentForCircle Calculates the moment of inertia for the circle of mass m.
MomentForPoly Calculates the moment of inertia for the polygons of mass m.
ResetShapeIdCounter Resets the shape id counter.
Vec2 Convenience function for the creation of a CPVect of x, y.

Types Summary

CPBB A simple bounding box.
CPBody A rigid body holds the physical properties of an object. (mass, position, velocity, etc.)
CPCircleShape A circle shape.
CPContact The contact point of a collision between two shapes.
CPGrooveJoint Attaches a point on one body to a groove on the other.
CPJoint Base type for joints.
CPPinJoint Connects two rigid bodies with a solid pin or rod.
CPPivotJoint Allows two objects to pivot about a single point.
CPPolyShape A convex polygon shape.
CPSegmentShape A line segment shape.
CPShape A collision shape.
CPSlideJoint Like pin joints, but have a minimum and maximum distance.
CPSpace Spaces are the basic simulation unit in Chipmunk.
CPSpaceHash The spatial hash is Chipmunk's default (and currently only) spatial index type.
CPVect A 2D vector.

Globals

Global CPVZero:CPVect
DescriptionA standard 0,0 vector.

Functions

Function DampedSpring(a:CPBody, b:CPBody, anchor1:CPVect, anchor2:CPVect, rlen:Float, k:Float, dmp:Float, dt:Float)
DescriptionApply a spring force between bodies a and b at anchors anchor1 and anchor2 respectively.
Informationk 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.

Function InitChipmunk()
DescriptionInitializes the physics engine.

Function MomentForCircle:Float(m:Float, r1:Float, r2:Float, offset:CPVect)
DescriptionCalculates the moment of inertia for the circle of mass m.

Function MomentForPoly:Float(m:Float, verts:CPVect[], offset:CPVect)
DescriptionCalculates the moment of inertia for the polygons of mass m.

Function ResetShapeIdCounter()
DescriptionResets the shape id counter.
InformationChipmunk keeps a counter so that every new shape is given a unique hash value to be used in the spatial hash. Because this affects the order in which the collisions are found and handled, you should reset the shape counter every time you populate a space with new shapes. If you don't, there might be (very) slight differences in the simulation.

Function Vec2:CPVect(x:Float, y:Float)
DescriptionConvenience function for the creation of a CPVect of x, y.

Types

Type CPBB
DescriptionA simple bounding box.
InformationStored as left, bottom, right, top values.
Methods Summary
ClampVect Returns a copy of v clamped to the bounding box.
ContainsBB Returns True if the bounding box completely contains other.
ContainsVect Returns True if the bounding box contains v.
Create Creates a new bounding box.
Intersects Returns True if the bounding boxes intersect.
WrapVect Returns a copy of v wrapped to the bounding box.
Method ClampVect:CPVect(v:CPVect)
DescriptionReturns a copy of v clamped to the bounding box.
Method ContainsBB:Int(other:CPBB)
DescriptionReturns True if the bounding box completely contains other.
Method ContainsVect:Int(v:CPVect)
DescriptionReturns True if the bounding box contains v.
Method Create:CPBB(l:Float, b:Float, r:Float, t:Float)
DescriptionCreates a new bounding box.
Method Intersects:Int(other:CPBB)
DescriptionReturns True if the bounding boxes intersect.
Method WrapVect:CPVect(v:CPVect)
DescriptionReturns a copy of v wrapped to the bounding box.

Type CPBody Extends CPObject
DescriptionA rigid body holds the physical properties of an object. (mass, position, velocity, etc.)
InformationIt does not have a shape by itself. By attaching shapes to bodies, you can define the a body's shape. You can attach many shapes to a single body to define a complex shape, or none if it doesn't require a shape.
Methods Summary
ApplyForce Apply (accumulate) the force on body with offset.
ApplyImpulse Apply the impulse to the body with offset.
Create Creates a new body.
Free Frees the body.
GetAngle Gets the current angle for the body.
GetAngularVelocity Returns the body angular velocity.
GetData Retrieves user data for the body, or Null if not set.
GetInertia Returns the body inertia.
GetMass Returns the body mass.
GetPosition Gets the body position.
GetRot  
GetTorque Returns the body torque.
GetVelocity Returns the body velocity.
Local2World Convert body local to world coordinates.
ResetForces Zero both the forces and torques accumulated on body.
SetAngle Sets the body angle.
SetAngularVelocity Sets the body angular velocity.
SetData Sets user data for the body.
SetMass Sets the body mass.
SetMoment Sets the body moment.
SetPosition Sets the body position.
SetPositionFunction Sets the position function.
SetTorque Sets the body torque.
SetVelocity Sets the body velocity.
SetVelocityFunction Sets the velocity function.
Slew Modify the velocity of an object so that it will slew.
UpdatePosition Updates the position of the body using Euler integration.
UpdateVelocity Updates the velocity of the body using Euler integration.
World2Local Convert world to body local coordinates.
Method ApplyForce(force:CPVect, offset:CPVect)
DescriptionApply (accumulate) the force on body with offset.
InformationBoth force and offset should be in world coordinates.
Method ApplyImpulse(impulse:CPVect, offset:CPVect)
DescriptionApply the impulse to the body with offset.
InformationBoth impulse and offset should be in world coordinates.
Method Create:CPBody(mass:Float, inertia:Float)
DescriptionCreates a new body.
Method Free()
DescriptionFrees the body.
Method GetAngle:Float()
DescriptionGets the current angle for the body.
Method GetAngularVelocity:Float()
DescriptionReturns the body angular velocity.
Method GetData:Object()
DescriptionRetrieves user data for the body, or Null if not set.
Method GetInertia:Float()
DescriptionReturns the body inertia.
Method GetMass:Float()
DescriptionReturns the body mass.
Method GetPosition:CPVect()
DescriptionGets the body position.
Method GetRot:CPVect()
Method GetTorque:Float()
DescriptionReturns the body torque.
Method GetVelocity:CPVect()
DescriptionReturns the body velocity.
Method Local2World:CPVect(vec:CPVect)
DescriptionConvert body local to world coordinates.
Method ResetForces()
DescriptionZero both the forces and torques accumulated on body.
Method SetAngle(angle:Float)
DescriptionSets the body angle.
Method SetAngularVelocity(av:Float)
DescriptionSets the body angular velocity.
Method SetData(data:Object)
DescriptionSets user data for the body.
Method SetMass(mass:Float)
DescriptionSets the body mass.
Method SetMoment(moment:Float)
DescriptionSets the body moment.
Method SetPosition(pos:CPVect)
DescriptionSets the body position.
Method SetPositionFunction(func(Body:CPBody, dt:Float))
DescriptionSets the position function.
Method SetTorque(torque:Float)
DescriptionSets the body torque.
Method SetVelocity(velocity:CPVect)
DescriptionSets the body velocity.
Method SetVelocityFunction(func(Body:CPBody, gravity:CPVect, damping:Float, dt:Float))
DescriptionSets the velocity function.
Method Slew(pos:CPVect, dt:Float)
DescriptionModify the velocity of an object so that it will slew.
Method UpdatePosition(dt:Float)
DescriptionUpdates the position of the body using Euler integration.
InformationLike UpdateVelocity() you shouldn't normally need to call this yourself.
Method UpdateVelocity(gravity:CPVect, damping:Float, dt:Float)
DescriptionUpdates the velocity of the body using Euler integration.
InformationYou don't need to call this unless you are managing the object manually instead of adding it to a CPSpace.
Method World2Local:CPVect(vec:CPVect)
DescriptionConvert world to body local coordinates.

Type CPCircleShape Extends CPShape
DescriptionA circle shape.
InformationThe fastest collision shape. They also roll smoothly.
Methods Summary
Create Creates a new circle shape.
GetCenter Returns the shape center, in body space coordinates.
GetRadius Returns the shape radius.
GetTransformedCenter Returns the transformed shape center, in world coordinates.
Method Create:CPCircleShape(body:CPBody, radius:Float, offset:CPVect)
DescriptionCreates a new circle shape.
Informationbody is the body attach the circle to, offset is the offset from the body's center of gravity in body local coordinates.
Method GetCenter:CPVect()
DescriptionReturns the shape center, in body space coordinates.
Method GetRadius:Float()
DescriptionReturns the shape radius.
Method GetTransformedCenter:CPVect()
DescriptionReturns the transformed shape center, in world coordinates.

Type CPContact
DescriptionThe contact point of a collision between two shapes.
Methods Summary
GetDistance Returns the penetration distance of the collision.
GetNormal Returns the normal of the collision.
GetNormalAccumulatedImpulse Returns the normal component of the accumulated (final) impulse applied to resolve the collision.
GetPosition Returns the position of the collision.
GetTangentAccumulatedImpulse Returns the tangential component of the accumulated (final) impulse applied to resolve the collision.
Method GetDistance:Float()
DescriptionReturns the penetration distance of the collision.
Method GetNormal:CPVect()
DescriptionReturns the normal of the collision.
Method GetNormalAccumulatedImpulse:Float()
DescriptionReturns the normal component of the accumulated (final) impulse applied to resolve the collision.
InformationThis value is not valid until after the call to DoStep() returns.
Method GetPosition:CPVect()
DescriptionReturns the position of the collision.
Method GetTangentAccumulatedImpulse:Float()
DescriptionReturns the tangential component of the accumulated (final) impulse applied to resolve the collision.
InformationThis value is not valid until after the call to DoStep() returns.

Type CPGrooveJoint Extends CPJoint
DescriptionAttaches a point on one body to a groove on the other.
InformationThink of it as a sliding pivot joint.
Methods Summary
Create Creates a new groove joint.
GetAnchor Anchor point.
GetGrooveA Groove A location.
GetGrooveB Groove B location.
Method Create:CPGrooveJoint(bodyA:CPBody, bodyB:CPBody, grooveA:CPVect, grooveB:CPVect, anchor:CPVect)
DescriptionCreates a new groove joint.
InformationThe groove goes from grooveA to grooveB on bodyA, and the pivot is attached to anchor on bodyB. All coordinates are body local.
Method GetAnchor:CPVect()
DescriptionAnchor point.
Method GetGrooveA:CPVect()
DescriptionGroove A location.
Method GetGrooveB:CPVect()
DescriptionGroove B location.

Type CPJoint Extends CPObject
DescriptionBase type for joints.
Methods Summary
GetBodyA Body A.
GetBodyB Body B.
Method GetBodyA:CPBody()
DescriptionBody A.
Method GetBodyB:CPBody()
DescriptionBody B.

Type CPPinJoint Extends CPJoint
DescriptionConnects two rigid bodies with a solid pin or rod.
InformationIt keeps the anchor points at a set distance from one another.
Methods Summary
Create Creates a new pin joint.
GetAnchor1 Anchor point 1.
GetAnchor2 Anchor point 2.
Method Create:CPPinJoint(bodyA:CPBody, bodyB:CPBody, anchor1:CPVect, anchor2:CPVect)
DescriptionCreates a new pin joint.
Method GetAnchor1:CPVect()
DescriptionAnchor point 1.
Method GetAnchor2:CPVect()
DescriptionAnchor point 2.

Type CPPivotJoint Extends CPJoint
DescriptionAllows two objects to pivot about a single point.
Methods Summary
Create Creates a new pivot joint.
GetAnchor1 Anchor point 1.
GetAnchor2 Anchor point 2.
Method Create:CPPivotJoint(bodyA:CPBody, bodyB:CPBody, pivot:CPVect)
DescriptionCreates a new pivot joint.
InformationbodyA and bodyB are the two bodies to connect, and pivot is the point in world coordinates of the pivot. Because the pivot location is given in world coordinates, you must have the bodies moved into the correct positions already.
Method GetAnchor1:CPVect()
DescriptionAnchor point 1.
Method GetAnchor2:CPVect()
DescriptionAnchor point 2.

Type CPPolyShape Extends CPShape
DescriptionA convex polygon shape.
InformationThe slowest, but most flexible collision shape.
Methods Summary
Create Creates a new convex polygon shape.
GetVerts Returns the array of vertices.
GetVertsAsCoords Returns the vertices as an array of floats.
Method Create:CPPolyShape(body:CPBody, verts:CPVect[], offset:CPVect)
DescriptionCreates a new convex polygon shape.
Informationbody is the body to attach the poly to, verts is an array of CPVect's defining a convex hull with a counterclockwise winding, offset is the offset from the body's center of gravity in body local coordinates.
Method GetVerts:CPVect[]()
DescriptionReturns the array of vertices.
Method GetVertsAsCoords:Float[]()
DescriptionReturns the vertices as an array of floats.

Type CPSegmentShape Extends CPShape
DescriptionA line segment shape.
InformationMeant mainly as a static shape. They can be attached to moving bodies, but they don't generate collisions with other line segments.
Methods Summary
Create Creates a new line segment shape.
GetEndPointA Returns the position of endpoint A.
GetEndPointB Returns the position of endpoint B.
GetNormal Returns the segment normal.
Method Create:CPSegmentShape(body:CPBody, a:CPVect, b:CPVect, radius:Float)
DescriptionCreates a new line segment shape.
Informationbody is the body to attach the segment to, a and b are the endpoints, and radius is the thickness of the segment.
Method GetEndPointA:CPVect()
DescriptionReturns the position of endpoint A.
Method GetEndPointB:CPVect()
DescriptionReturns the position of endpoint B.
Method GetNormal:CPVect()
DescriptionReturns the segment normal.

Type CPShape Extends CPObject
DescriptionA collision shape.
InformationBy attaching shapes to bodies, you can define the a body's shape. You can attach many shapes to a single body to define a complex shape, or none if it doesn't require a shape.

There is often confusion between rigid bodies and their collision shapes in Chipmunk and how they relate to sprites. A sprite would be a visual representation of an object, the sprite is drawn at the position of the rigid body. The collision shape would be the material representation of the object, and how it should collide with other objects. A sprite and collision shape have little to do with one another other than you probably want the collision shape to match the sprite's shape.

Methods Summary
CacheBB Updates and returns the bounding box of the shape.
Free Frees the shape.
GetBody Returns the rigid body the shape is attached to.
GetData Retrieves user data for the body, or Null if not set.
GetElasticity Returns the shape elasticity.
GetFriction Returns the shape friction.
GetSurfaceVelocity Returns the surface velocity of the object.
SetCollisionType Sets the user-definable type field.
SetData Sets user data for the body.
SetElasticity Sets the elasticity of the shape.
SetFriction Sets the friction coefficient for the shape.
SetGroup Sets the group to which this shape belongs.
SetLayers Sets the layers this shape occupies.
SetSurfaceVelocity Sets the surface velocity of the object.
Method CacheBB:CPBB()
DescriptionUpdates and returns the bounding box of the shape.
Method Free()
DescriptionFrees the shape.
Method GetBody:CPBody()
DescriptionReturns the rigid body the shape is attached to.
Method GetData:Object()
DescriptionRetrieves user data for the body, or Null if not set.
Method GetElasticity:Float()
DescriptionReturns the shape elasticity.
Method GetFriction:Float()
DescriptionReturns the shape friction.
Method GetSurfaceVelocity:CPVect()
DescriptionReturns the surface velocity of the object.
Method SetCollisionType(kind:Int)
DescriptionSets the user-definable type field.
Method SetData(data:Object)
DescriptionSets user data for the body.
Method SetElasticity(e:Float)
DescriptionSets the elasticity of the shape.
InformationA value of 0.0 gives no bounce, while a value of 1.0 will give a "perfect" bounce. However due to inaccuracies in the simulation using 1.0 or greater is not recommended however.

The amount of elasticity applied during a collision is determined by multiplying the elasticity of both shapes together.

Method SetFriction(u:Float)
DescriptionSets the friction coefficient for the shape.
InformationChipmunk uses the Coulomb friction model, a value of 0.0 is frictionless. Tables of friction coefficients.

The amount of friction applied during a collision is determined by multiplying the friction of both shapes together.

Method SetGroup(group:Int)
DescriptionSets the group to which this shape belongs.
InformationShapes in the same non-zero group do not generate collisions. Useful when creating an object out of many shapes that you don't want to self collide. Defaults to 0.
Method SetLayers(layers:Int)
DescriptionSets the layers this shape occupies.
InformationShapes only collide if they are in the same bit-planes. i.e. (a.layers
 b.layers) != 0.

By default, a shape occupies all 32 bit-planes.

Method SetSurfaceVelocity(velocity:CPVect)
DescriptionSets the surface velocity of the object.
InformationUseful for creating conveyor belts or players that move around. This value is only used when calculating friction, not the collision.

Type CPSlideJoint Extends CPJoint
DescriptionLike pin joints, but have a minimum and maximum distance.
InformationA chain could be modeled using this joint. It keeps the anchor points from getting to far apart, but will allow them to get closer together.
Methods Summary
Create Creates a new slide joint.
GetAnchor1 Anchor point 1.
GetAnchor2 Anchor point 2.
GetMaxDist Maximum allowed distance of the anchor points.
GetMinDist Minimum allowed distance of the anchor points.
Method Create:CPSlideJoint(bodyA:CPBody, bodyB:CPBody, anchor1:CPVect, anchor2:CPVect, minDist:Float, maxDist:Float)
DescriptionCreates a new slide joint.
Method GetAnchor1:CPVect()
DescriptionAnchor point 1.
Method GetAnchor2:CPVect()
DescriptionAnchor point 2.
Method GetMaxDist:Float()
DescriptionMaximum allowed distance of the anchor points.
Method GetMinDist:Float()
DescriptionMinimum allowed distance of the anchor points.

Type CPSpace Extends CPObject
DescriptionSpaces are the basic simulation unit in Chipmunk.
InformationYou add bodies, shapes and joints to a space, and then update the space as a whole.

Notes

  • When removing objects from the space, make sure you remove any other objects that reference it. For instance, when you remove a body, remove the joints and shapes attached to it.
  • The number of iterations, and the size of the time step determine the quality of the simulation. More iterations, or smaller time steps increase the quality.
  • Because static shapes are only rehashed when you request it, it's possible to use a much higher count argument to CPHash.ResizeStaticHash() than to cpHashResizeStaticHash(). Doing so will use more memory though.
Methods Summary
AddBody Adds a body to the space.
AddCollisionPairFunc Register cpCollFunc to be called when a collision is found between a shapes with collision type fields that match collTypeA and collTypeB.
AddJoint  
AddShape Adds a shape to the space.
AddStaticShape Adds a static shape to the space.
Create Creates a new CPSpace.
DoStep Update the space for the given time step.
EachBody Starts an iteration over every body of this space, calling callback for each.
Free Frees the CPSpace and all dependencies.
GetActiveShapes Returns the hash of active shapes.
GetStaticShapes Returns the hash of static shapes.
RehashStatic Rehashes the shapes in the static spatial hash.
RemoveCollisionPairFunc Remove the function for the given collision type pair.
ResizeActiveHash Resizes the active hash table.
ResizeStaticHash Resizes the static hash table.
SetDamping Sets the amount of viscous damping applied to the system.
SetDefaultCollisionPairFunc The default function is called when no collision pair function is specified.
SetGravity Sets the amount of gravity applied to the system.
SetIterations Sets the number of iterations to use when solving constraints (collisions and joints).
Method AddBody(body:CPBody)
DescriptionAdds a body to the space.
Method AddCollisionPairFunc(collTypeA:Int, collTypeB:Int, cpCollFunc:Int(shapeA:CPShape, shapeB:CPShape, contacts:CPContact[], normalCoeficient:Float, data:Object), data:Object = Null)
DescriptionRegister cpCollFunc to be called when a collision is found between a shapes with collision type fields that match collTypeA and collTypeB.
Informationdata is passed to the function as a parameter. The ordering of the collision types will match the ordering passed to the callback function.

Collision pair functions allow you to add callbacks for certain collision events. Each CPShape structure has a user definable collisionType field that is used to identify its type. For instance, you could define an enumeration of collision types such as bullets and players, and then register a collision pair function to reduce the players health when a collision is found between the two.

Additionally, the return value of a collision pair function determines whether or not a collision will be processed. If the function returns False, the collision will be ignored. One use for this functionality is to allow a rock object to break a vase object. If the approximated energy of the collision is above a certain level, flag the vase to be removed from the space, apply an impulse to the rock to slow it down, and return False. After the DoStep() returns, remove the vase from the space.

WARNING: It is not safe for collision pair functions to remove or free shapes or bodies from a space. Doing so will likely end in a segfault as an earlier collision may already be referencing the shape or body. You must wait until after the DoStep() method returns.

Method AddJoint(joint:CPJoint)
Method AddShape(shape:CPShape)
DescriptionAdds a shape to the space.
Method AddStaticShape(shape:CPShape)
DescriptionAdds a static shape to the space.
InformationShapes added as static are assumed not to move. Static shapes should be be attached to a rigid body with an infinite mass and moment of inertia. Also, don't add the rigid body used to the space, as that will cause it to fall under the effects of gravity.
Method Create:CPSpace()
DescriptionCreates a new CPSpace.
Method DoStep(dt:Float)
DescriptionUpdate the space for the given time step.
InformationUsing a fixed time step is highly recommended. Doing so will increase the efficiency of the contact persistence, requiring an order of magnitude fewer iterations to resolve the collisions in the usual case.
Method EachBody(callback(obj:Object, data:Object), data:Object = Null)
DescriptionStarts an iteration over every body of this space, calling callback for each.
Method Free()
DescriptionFrees the CPSpace and all dependencies.
Method GetActiveShapes:CPSpaceHash()
DescriptionReturns the hash of active shapes.
Method GetStaticShapes:CPSpaceHash()
DescriptionReturns the hash of static shapes.
Method RehashStatic()
DescriptionRehashes the shapes in the static spatial hash.
InformationYou only need to call this if you move one of the static shapes.
Method RemoveCollisionPairFunc(collTypeA:Int, collTypeB:Int)
DescriptionRemove the function for the given collision type pair.
InformationThe order of collTypeA and collTypeB must match the original order used with AddCollisionPairFunc().
Method ResizeActiveHash(dim:Float, count:Int)
DescriptionResizes the active hash table.
InformationThe spatial hashes used by Chipmunk's collision detection are fairly size sensitive. dim is the size of the hash cells. Setting dim to the average objects size is likely to give the best performance.

count is the suggested minimum number of cells in the hash table. Bigger is better, but only to a point. Setting count to ~10x the number of objects in the hash is probably a good starting point.

By default, dim is 100.0, and count is 1000.

Method ResizeStaticHash(dim:Float, count:Int)
DescriptionResizes the static hash table.
InformationThe spatial hashes used by Chipmunk's collision detection are fairly size sensitive. dim is the size of the hash cells. Setting dim to the average objects size is likely to give the best performance.

count is the suggested minimum number of cells in the hash table. Bigger is better, but only to a point. Setting count to ~10x the number of objects in the hash is probably a good starting point.

By default, dim is 100.0, and count is 1000.

Method SetDamping(damping:Float)
DescriptionSets the amount of viscous damping applied to the system.
Method SetDefaultCollisionPairFunc(cpCollFunc(shapeA:CPShape, shapeB:CPShape, contacts:CPContact[], normalCoeficient:Float, data:Object), data:Object = Null)
DescriptionThe default function is called when no collision pair function is specified.
InformationBy default, the default function simply accepts all collisions. Passing Null for cpCollFunc will reset the default function back to the default. (You know what I mean.)

Passing Null for cpCollFunc will reject collisions by default.

Method SetGravity(vec:CPVect)
DescriptionSets the amount of gravity applied to the system.
Method SetIterations(num:Int)
DescriptionSets the number of iterations to use when solving constraints (collisions and joints).
InformationDefaults to 10.

Type CPSpaceHash Extends cpObject
DescriptionThe spatial hash is Chipmunk's default (and currently only) spatial index type.
InformationBased on a chained hash table.
Methods Summary
ForEach Iterate over the objects in the hash, calling callback for each.
Method ForEach(callback(obj:Object, data:Object), data:Object = Null)
DescriptionIterate over the objects in the hash, calling callback for each.
Informationdata is some optional user data that will be passed to callback.

Type CPVect
DescriptionA 2D vector.
Methods Summary
Add Adds vec to this vector, returning the new combined vector.
Create Creates a new CPVect.
Cross 2D vector cross product analog.
Dot Vector dot product.
GetX X.
GetY Y.
Length Returns the length of the vector.
LengthSq Returns the squared length of the vector.
Mult Scalar multiplication.
Negate Negate a vector.
Normalize Returns a normalized copy of the vector.
Perp Returns the perpendicular vector. (90 degree rotation)
Project Returns the vector projection of the vector onto vec.
Rotate Uses complex multiplication to rotate (and scale) this vector by vec.
Sub Subtracts vec from this vector, returning the new combined vector.
ToAngle Returns the angular direction the vector is pointing in (in degrees).
UnRotate Inverse of Rotate().
Method Add:CPVect(vec:CPVect)
DescriptionAdds vec to this vector, returning the new combined vector.
Method Create:CPVect(_x:Float, _y:Float)
DescriptionCreates a new CPVect.
Method Cross:Float(vec:CPVect)
Description2D vector cross product analog.
InformationThe cross product of 2D vectors exists only in the z component, so only that value is returned.
Method Dot:Float(vec:CPVect)
DescriptionVector dot product.
Method GetX:Float()
DescriptionX.
Method GetY:Float()
DescriptionY.
Method Length:Float()
DescriptionReturns the length of the vector.
Method LengthSq:Float()
DescriptionReturns the squared length of the vector.
InformationFaster than Length() when you only need to compare lengths.
Method Mult:CPVect(scalar:Float)
DescriptionScalar multiplication.
Method Negate:CPVect()
DescriptionNegate a vector.
Method Normalize:CPVect()
DescriptionReturns a normalized copy of the vector.
Method Perp:CPVect()
DescriptionReturns the perpendicular vector. (90 degree rotation)
Method Project:CPVect(vec:CPVect)
DescriptionReturns the vector projection of the vector onto vec.
Method Rotate:CPVect(vec:CPVect)
DescriptionUses complex multiplication to rotate (and scale) this vector by vec.
Method Sub:CPVect(vec:CPVect)
DescriptionSubtracts vec from this vector, returning the new combined vector.
Method ToAngle:Float()
DescriptionReturns the angular direction the vector is pointing in (in degrees).
Method UnRotate:CPVect(vec:CPVect)
DescriptionInverse of Rotate().

Module Information

Version1.03
LicenseMIT
CopyrightWrapper - 2007 Bruce A Henderson
ModserverBRL
History1.03
HistoryAdded user Set/GetData() methods for CPBody and CPShape.
History1.02
HistoryUpdate to latest Chipmunk source.
HistoryAdded callbacks for body velocity and position.
History1.01
HistoryAdds body SetTorque().
HistoryAdds joint Free().
HistoryFixes problem where Free'ing wasn't removing the objects from the space.
History1.00
HistoryInitial release.
CC_OPTS-std=gnu99