LineJoint
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
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.
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.
Anchor point on first Body, defining position on line.
This anchor point is defined in the local coordinate system of body1.
Anchor point on second Body.
This anchor point is defined in the local coordinate system of body2.
Direction of line on first Body.
This direction is defined in the local coordinate system of body1 and
need not be normalised.
Lower bound for constraint.
This value must be less than or equal to jointMax.
Upper bound for constraint.
This value must be greater than or equal to jointMin.
@inheritDoc
For this constraint, the MatMN will be 2x1.
Returns |
---|
nape.geom.MatMN |
@inheritDoc
Name | Type |
---|---|
body |
nape.phys.Body |
Returns |
---|
nape.geom.Vec3 |
@inheritDoc
Name | Type |
---|---|
lambda |
Function |
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 |
- |