LineJoint constraining anchor of one body, to a line segment of the other.
The equation for this constraint could be written like:
where:0 = [dir.cross(delta)] = 0
jointMin <= [dor.dot (delta)] <= jointMax
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.
Constructor
new(body1:Null<Body>, body2:Null<Body>, anchor1:Vec2, anchor2:Vec2, direction:Vec2, jointMin:Float, jointMax:Float)
Construct a new LineJoint.
Parameters:
body1 | The first body in LineJoint. |
---|---|
body2 | The second body in LineJoint. |
anchor1 | The first local anchor for joint. |
anchor2 | The second local anchor for joint. |
direction | The direction of local line for joint. |
jointMin | The lower bound for constraint. |
jointMax | The upper bound for constraint. |
Returns:
The constructed LineJoint.
Variables
anchor1:Vec2
Anchor point on first Body, defining position on line.
This anchor point is defined in the local coordinate system of body1.
anchor2:Vec2
Anchor point on second Body.
This anchor point is defined in the local coordinate system of body2.
body1:Null<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.
body2:Null<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.