LineJoint

Constraintnape.constraint.LineJoint (final class)

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

The equation for this constraint could be written like:

0  = [dir.cross(delta)]  = 0
jointMin <= [dor.dot  (delta)] <= jointMax

where:

dir   = body1.localVectorToWorld(direction).unit();
delta = body2.localPointToWorld(anchor2).sub(body1.localPointToWorld(anchor1));

This is a 2 dimensional constraint, and is (when at the limits) solved as a block constraint for better stability. This is however not the most stable of joint when chained and put under stress and is a rather rare case where using a non-stiff joint can actually be more stable than using a stiff one.

When jointMin = jointMax , it would be better to use a PivotJoint instead with suitable placed anchors.

The line segment is defined implicitly via the anchor1, direction, jointMin and jointMax properties with end points defined in local coordinate system of body1 like:

start = anchor1.add(direction.unit().mul(jointMin))
end   = anchor1.add(direction.unit().mul(jointMax))

The reason for this more general description of a line segment is that one or both of jointMin, jointMax are permitted to be infinite and a line segment defined with a start and end point is not sufficient to describe such lines.

Instance Members

@private


nape
body1: Null<nape.phys.Body>

First Body in constraint, defining the line segment.

This value may be null, but trying to simulate the constraint whilst this body is null will result in an error.


nape
body2: Null<nape.phys.Body>

Second Body in constraint.

This value may be null, but trying to simulate the constraint whilst this body is null will result in an error.


nape
anchor1: nape.geom.Vec2

Anchor point on first Body, defining position on line.

This anchor point is defined in the local coordinate system of body1.


nape
anchor2: nape.geom.Vec2

Anchor point on second Body.

This anchor point is defined in the local coordinate system of body2.


nape
direction: nape.geom.Vec2

Direction of line on first Body.

This direction is defined in the local coordinate system of body1 and need not be normalised.


nape
jointMin: Float

Lower bound for constraint.

This value must be less than or equal to jointMax.


nape
jointMax: Float

Upper bound for constraint.

This value must be greater than or equal to jointMin.


nape
impulse(): nape.geom.MatMN

@inheritDoc

For this constraint, the MatMN will be 2x1.

Returns
nape.geom.MatMN

nape
bodyImpulse(body: nape.phys.Body): nape.geom.Vec3

@inheritDoc

Name Type
body nape.phys.Body
Returns
nape.geom.Vec3

nape
visitBodies(lambda: Function): Void

@inheritDoc

Name Type
lambda Function

nape
new(body1: Null<nape.phys.Body>, body2: Null<nape.phys.Body>, anchor1: nape.geom.Vec2, anchor2: nape.geom.Vec2, direction: nape.geom.Vec2, jointMin: Float, jointMax: Float): Void

Construct a new LineJoint.

Name Type Description
body1 Null<nape.phys.Body> The first body in LineJoint.
body2 Null<nape.phys.Body> The second body in LineJoint.
anchor1 nape.geom.Vec2 The first local anchor for joint.
anchor2 nape.geom.Vec2 The second local anchor for joint.
direction nape.geom.Vec2 The direction of local line for joint.
jointMin Float The lower bound for constraint.
jointMax Float The upper bound for constraint.

Private Members

Metadata

Name Parameters
:final -