nape.constraint

..
AngleJoint

AngleJoint constraining the relative angles of two Bodies.

The equation for this constraint is:

jointMin <= ratio * body2.rotation - body1.rotation <= jointMax

Constraint

Base type for all Nape joints and constraints

ConstraintIterator

Haxe Iterator compatible iterator over Nape list.

ConstraintList

Nape list of Constraint type objects

Internally this list is at present implemented as a linked list with object pooled nodes and iterators with various fast paths made for standard access patterns (For instance accessing successive elements runs in constant time when using random access functions)

Iteration of this list can be done in various ways, but the preferred way on all targets, is through use of the foreach function:

list.foreach(function (obj) {
});
This method is inlined so that in haxe no closure will need to be created.

In AS3, a closure would need to be created in general, so for performance reasons you 'may' choose to use iteration as follows:
for (var i:int = 0; i < list.length; i++) {

DistanceJoint

DistanceJoint limiting the distance between two local anchor points of Bodies.

The equation for this constraint could be written like:

jointMin <= distance(body2.localPointToWorld(anchor2), body1.localPointToWorld(anchor1)) <= jointMax
This joint is not designed to work when jointMin = jointMax = 0 and constraint is stiff. In this instance you should use a PivotJoint instead.

LineJoint

LineJoint constraining anchor of one body, to a line segment of the other.

The equation for this constraint could be written like:

MotorJoint

MotorJoint constraining the angular velocities of two bodies

The equation for this constraint is:

(ratio * body2.angularVel) - body1.angularVel = rate
This constraint operates only on the velocities of objects.

PivotJoint

PivotJoint constraining two anchors points of bodies to be equal.

The equation for this constraint is:

body2.localPointToWorld(anchor2) = body1.localPointToWorld(anchor1)
You may view this constraint as being equal to the DistanceJoint constraint when both its jointMin and jointMax are exactly 0 (In such a case a DistanceJoint becomes degenerate). Compared to the DistanceJoint this is a 2 dimensional constraint.

PulleyJoint

PulleyJoint limiting the weighted sum of distances between 2 pairs of 4 local anchor points of Bodies.

The equation for this constraint could be written like:

jointMin <= distance(body2.localPointToWorld(anchor2), body1.localPointToWorld(anchor1))
+ ratio * distance(body4.localPointToWorld(anchor4), body3.localPointToWorld(anchor3)) <= jointMax
This joint is not designed to work when either of these pairs achieves a distance of 0, it will still work but may not be entirely ideal. !1*

* This constraint can be used in a full 4-body set up, or a 3-body set up or a 2-body set up permitting any arrangement as long as body1 != body2 and body3 != body4

UserConstraint

UserConstraint providing a low-level API for user-defined Constraints.

This API is intended to be powerful enough to model any constraint that Nape can handle, but not so low level as to be completely prohibitive.
For instance, things like soft-constraints are automatically provided by this API.

Working with this API will require mathematical skills. A full manual for this API is provided at: http://napephys.com/help/Constraints.pdf

You may also be interested in the nape-symbolic module that is available on github/haxelib/nape downloads. Which provides a run-time compiled DSL using this API to make prototyping (or creating non-performance critical) user-defined constraints simple without the need for great mathematical skills as well as being much quicker to work with.

WeldJoint

WeldJoint constraining two bodies to be exactly locked together.

The equation for this constraint is:

[ body2.localPointToWorld(anchor2) ] = [ body1.localPointToWorld(anchor1) ]
[          body2.rotation          ]   [      body1.rotation + phase      ]
This constraint is equivalent to using a PivotJoint and AngleJoint together except that it is solved as a single constraint and thus will be more stable.

This constraint is 3 dimensional.

Although this constraint is very stable, if you chain bodies together using this constraint, you should except to see a small amount of rotation about the anchor points so you should chose them accordingly.