BaH.Chipmunk: | Globals | Functions | Types | Modinfo | Source |
CPVZero |
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. |
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. |
Global CPVZero:CPVect | |
Description | A standard 0,0 vector. |
Function DampedSpring(a:CPBody, b:CPBody, anchor1:CPVect, anchor2:CPVect, rlen:Float, k:Float, dmp:Float, dt:Float) | |
Description | Apply a spring force between bodies a and b at anchors anchor1 and anchor2 respectively. |
Information | 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. |
Function InitChipmunk() | |
Description | Initializes the physics engine. |
Function MomentForCircle:Float(m:Float, r1:Float, r2:Float, offset:CPVect) | |
Description | Calculates the moment of inertia for the circle of mass m. |
Function MomentForPoly:Float(m:Float, verts:CPVect[], offset:CPVect) | |
Description | Calculates the moment of inertia for the polygons of mass m. |
Function ResetShapeIdCounter() | |
Description | Resets the shape id counter. |
Information | Chipmunk 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) | |
Description | Convenience function for the creation of a CPVect of x, y. |
Type CPBB | |
Description | A simple bounding box. |
Information | Stored 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) | |
Description | Returns a copy of v clamped to the bounding box. |
Method ContainsBB:Int(other:CPBB) | |
Description | Returns True if the bounding box completely contains other. |
Method ContainsVect:Int(v:CPVect) | |
Description | Returns True if the bounding box contains v. |
Method Create:CPBB(l:Float, b:Float, r:Float, t:Float) | |
Description | Creates a new bounding box. |
Method Intersects:Int(other:CPBB) | |
Description | Returns True if the bounding boxes intersect. |
Method WrapVect:CPVect(v:CPVect) | |
Description | Returns a copy of v wrapped to the bounding box. |
Type CPBody Extends CPObject | |
Description | A rigid body holds the physical properties of an object. (mass, position, velocity, etc.) |
Information | It 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) | |
Description | Apply (accumulate) the force on body with offset. |
Information | Both force and offset should be in world coordinates. |
Method ApplyImpulse(impulse:CPVect, offset:CPVect) | |
Description | Apply the impulse to the body with offset. |
Information | Both impulse and offset should be in world coordinates. |
Method Create:CPBody(mass:Float, inertia:Float) | |
Description | Creates a new body. |
Method Free() | |
Description | Frees the body. |
Method GetAngle:Float() | |
Description | Gets the current angle for the body. |
Method GetAngularVelocity:Float() | |
Description | Returns the body angular velocity. |
Method GetData:Object() | |
Description | Retrieves user data for the body, or Null if not set. |
Method GetInertia:Float() | |
Description | Returns the body inertia. |
Method GetMass:Float() | |
Description | Returns the body mass. |
Method GetPosition:CPVect() | |
Description | Gets the body position. |
Method GetRot:CPVect() |
Method GetTorque:Float() | |
Description | Returns the body torque. |
Method GetVelocity:CPVect() | |
Description | Returns the body velocity. |
Method Local2World:CPVect(vec:CPVect) | |
Description | Convert body local to world coordinates. |
Method ResetForces() | |
Description | Zero both the forces and torques accumulated on body. |
Method SetAngle(angle:Float) | |
Description | Sets the body angle. |
Method SetAngularVelocity(av:Float) | |
Description | Sets the body angular velocity. |
Method SetData(data:Object) | |
Description | Sets user data for the body. |
Method SetMass(mass:Float) | |
Description | Sets the body mass. |
Method SetMoment(moment:Float) | |
Description | Sets the body moment. |
Method SetPosition(pos:CPVect) | |
Description | Sets the body position. |
Method SetPositionFunction(func(Body:CPBody, dt:Float)) | |
Description | Sets the position function. |
Method SetTorque(torque:Float) | |
Description | Sets the body torque. |
Method SetVelocity(velocity:CPVect) | |
Description | Sets the body velocity. |
Method SetVelocityFunction(func(Body:CPBody, gravity:CPVect, damping:Float, dt:Float)) | |
Description | Sets the velocity function. |
Method Slew(pos:CPVect, dt:Float) | |
Description | Modify the velocity of an object so that it will slew. |
Method UpdatePosition(dt:Float) | |
Description | Updates the position of the body using Euler integration. |
Information | Like UpdateVelocity() you shouldn't normally need to call this yourself. |
Method UpdateVelocity(gravity:CPVect, damping:Float, dt:Float) | |
Description | Updates the velocity of the body using Euler integration. |
Information | You 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) | |
Description | Convert world to body local coordinates. |
Type CPCircleShape Extends CPShape | |
Description | A circle shape. |
Information | The 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) | |
Description | Creates a new circle shape. |
Information | body 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() | |
Description | Returns the shape center, in body space coordinates. |
Method GetRadius:Float() | |
Description | Returns the shape radius. |
Method GetTransformedCenter:CPVect() | |
Description | Returns the transformed shape center, in world coordinates. |
Type CPContact | |
Description | The 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() | |
Description | Returns the penetration distance of the collision. |
Method GetNormal:CPVect() | |
Description | Returns the normal of the collision. |
Method GetNormalAccumulatedImpulse:Float() | |
Description | Returns the normal component of the accumulated (final) impulse applied to resolve the collision. |
Information | This value is not valid until after the call to DoStep() returns. |
Method GetPosition:CPVect() | |
Description | Returns the position of the collision. |
Method GetTangentAccumulatedImpulse:Float() | |
Description | Returns the tangential component of the accumulated (final) impulse applied to resolve the collision. |
Information | This value is not valid until after the call to DoStep() returns. |
Type CPGrooveJoint Extends CPJoint | |
Description | Attaches a point on one body to a groove on the other. |
Information | Think 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) | |
Description | Creates a new groove joint. |
Information | The 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() | |
Description | Anchor point. |
Method GetGrooveA:CPVect() | |
Description | Groove A location. |
Method GetGrooveB:CPVect() | |
Description | Groove B location. |
Type CPJoint Extends CPObject | |
Description | Base type for joints. |
Methods Summary | |
---|---|
GetBodyA | Body A. |
GetBodyB | Body B. |
Method GetBodyA:CPBody() | |
Description | Body A. |
Method GetBodyB:CPBody() | |
Description | Body B. |
Type CPPinJoint Extends CPJoint | |
Description | Connects two rigid bodies with a solid pin or rod. |
Information | It 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) | |
Description | Creates a new pin joint. |
Method GetAnchor1:CPVect() | |
Description | Anchor point 1. |
Method GetAnchor2:CPVect() | |
Description | Anchor point 2. |
Type CPPivotJoint Extends CPJoint | |
Description | Allows 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) | |
Description | Creates a new pivot joint. |
Information | bodyA 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() | |
Description | Anchor point 1. |
Method GetAnchor2:CPVect() | |
Description | Anchor point 2. |
Type CPPolyShape Extends CPShape | |
Description | A convex polygon shape. |
Information | The 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) | |
Description | Creates a new convex polygon shape. |
Information | body 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[]() | |
Description | Returns the array of vertices. |
Method GetVertsAsCoords:Float[]() | |
Description | Returns the vertices as an array of floats. |
Type CPSegmentShape Extends CPShape | |
Description | A line segment shape. |
Information | Meant 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) | |
Description | Creates a new line segment shape. |
Information | body 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() | |
Description | Returns the position of endpoint A. |
Method GetEndPointB:CPVect() | |
Description | Returns the position of endpoint B. |
Method GetNormal:CPVect() | |
Description | Returns the segment normal. |
Type CPShape Extends CPObject | |
Description | A collision shape. |
Information | 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.
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() | |
Description | Updates and returns the bounding box of the shape. |
Method Free() | |
Description | Frees the shape. |
Method GetBody:CPBody() | |
Description | Returns the rigid body the shape is attached to. |
Method GetData:Object() | |
Description | Retrieves user data for the body, or Null if not set. |
Method GetElasticity:Float() | |
Description | Returns the shape elasticity. |
Method GetFriction:Float() | |
Description | Returns the shape friction. |
Method GetSurfaceVelocity:CPVect() | |
Description | Returns the surface velocity of the object. |
Method SetCollisionType(kind:Int) | |
Description | Sets the user-definable type field. |
Method SetData(data:Object) | |
Description | Sets user data for the body. |
Method SetElasticity(e:Float) | |
Description | Sets the elasticity of the shape. |
Information | A 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) | |
Description | Sets the friction coefficient for the shape. |
Information | Chipmunk 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) | |
Description | Sets the group to which this shape belongs. |
Information | Shapes 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) | |
Description | Sets the layers this shape occupies. |
Information | Shapes 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) | |
Description | Sets the surface velocity of the object. |
Information | Useful for creating conveyor belts or players that move around. This value is only used when calculating friction, not the collision. |
Type CPSlideJoint Extends CPJoint | |
Description | Like pin joints, but have a minimum and maximum distance. |
Information | A 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) | |
Description | Creates a new slide joint. |
Method GetAnchor1:CPVect() | |
Description | Anchor point 1. |
Method GetAnchor2:CPVect() | |
Description | Anchor point 2. |
Method GetMaxDist:Float() | |
Description | Maximum allowed distance of the anchor points. |
Method GetMinDist:Float() | |
Description | Minimum allowed distance of the anchor points. |
Type CPSpace Extends CPObject | |
Description | Spaces are the basic simulation unit in Chipmunk. |
Information | You add bodies, shapes and joints to a space, and then update the space as a whole.
Notes
|
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) | |
Description | Adds 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) | |
Description | Register cpCollFunc to be called when a collision is found between a shapes with collision type fields that match collTypeA and collTypeB. |
Information | data 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) | |
Description | Adds a shape to the space. |
Method AddStaticShape(shape:CPShape) | |
Description | Adds a static shape to the space. |
Information | Shapes 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() | |
Description | Creates a new CPSpace. |
Method DoStep(dt:Float) | |
Description | Update the space for the given time step. |
Information | Using 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) | |
Description | Starts an iteration over every body of this space, calling callback for each. |
Method Free() | |
Description | Frees the CPSpace and all dependencies. |
Method GetActiveShapes:CPSpaceHash() | |
Description | Returns the hash of active shapes. |
Method GetStaticShapes:CPSpaceHash() | |
Description | Returns the hash of static shapes. |
Method RehashStatic() | |
Description | Rehashes the shapes in the static spatial hash. |
Information | You only need to call this if you move one of the static shapes. |
Method RemoveCollisionPairFunc(collTypeA:Int, collTypeB:Int) | |
Description | Remove the function for the given collision type pair. |
Information | The order of collTypeA and collTypeB must match the original order used with AddCollisionPairFunc(). |
Method ResizeActiveHash(dim:Float, count:Int) | |
Description | Resizes the active hash table. |
Information | The 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) | |
Description | Resizes the static hash table. |
Information | The 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) | |
Description | Sets 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) | |
Description | The default function is called when no collision pair function is specified. |
Information | By 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) | |
Description | Sets the amount of gravity applied to the system. |
Method SetIterations(num:Int) | |
Description | Sets the number of iterations to use when solving constraints (collisions and joints). |
Information | Defaults to 10. |
Type CPSpaceHash Extends cpObject | |
Description | The spatial hash is Chipmunk's default (and currently only) spatial index type. |
Information | Based 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) | |
Description | Iterate over the objects in the hash, calling callback for each. |
Information | data is some optional user data that will be passed to callback. |
Type CPVect | |
Description | A 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) | |
Description | Adds vec to this vector, returning the new combined vector. |
Method Create:CPVect(_x:Float, _y:Float) | |
Description | Creates a new CPVect. |
Method Cross:Float(vec:CPVect) | |
Description | 2D vector cross product analog. |
Information | The cross product of 2D vectors exists only in the z component, so only that value is returned. |
Method Dot:Float(vec:CPVect) | |
Description | Vector dot product. |
Method GetX:Float() | |
Description | X. |
Method GetY:Float() | |
Description | Y. |
Method Length:Float() | |
Description | Returns the length of the vector. |
Method LengthSq:Float() | |
Description | Returns the squared length of the vector. |
Information | Faster than Length() when you only need to compare lengths. |
Method Mult:CPVect(scalar:Float) | |
Description | Scalar multiplication. |
Method Negate:CPVect() | |
Description | Negate a vector. |
Method Normalize:CPVect() | |
Description | Returns a normalized copy of the vector. |
Method Perp:CPVect() | |
Description | Returns the perpendicular vector. (90 degree rotation) |
Method Project:CPVect(vec:CPVect) | |
Description | Returns the vector projection of the vector onto vec. |
Method Rotate:CPVect(vec:CPVect) | |
Description | Uses complex multiplication to rotate (and scale) this vector by vec. |
Method Sub:CPVect(vec:CPVect) | |
Description | Subtracts vec from this vector, returning the new combined vector. |
Method ToAngle:Float() | |
Description | Returns the angular direction the vector is pointing in (in degrees). |
Method UnRotate:CPVect(vec:CPVect) | |
Description | Inverse of Rotate(). |
Version | 1.03 |
---|---|
License | MIT |
Copyright | Wrapper - 2007 Bruce A Henderson |
Modserver | BRL |
History | 1.03 |
History | Added user Set/GetData() methods for CPBody and CPShape. |
History | 1.02 |
History | Update to latest Chipmunk source. |
History | Added callbacks for body velocity and position. |
History | 1.01 |
History | Adds body SetTorque(). |
History | Adds joint Free(). |
History | Fixes problem where Free'ing wasn't removing the objects from the space. |
History | 1.00 |
History | Initial release. |
CC_OPTS | -std=gnu99 |