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.

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

@:value(null)zpp_inner_zn:ZPP_LineJoint = null

@private

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.

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.

direction:Vec2

Direction of line on first Body.

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

jointMin:Float

Lower bound for constraint.

This value must be less than or equal to jointMax.

jointMax:Float

Upper bound for constraint.

This value must be greater than or equal to jointMin.

Methods

impulse():MatMN

@inheritDoc

For this constraint, the MatMN will be 2x1.

bodyImpulse(body:Body):Vec3

@inheritDoc

visitBodies(lambda:Body ‑> Void):Void

@inheritDoc

Inherited Variables

Defined by Constraint

zpp_inner:ZPP_Constraint

@private

read onlyuserData:Dynamic<Dynamic>

Dynamic object for user to store additional data.

This object cannot be set, only its dynamically created properties may be set. In AS3 the type of this property is &#42

This object will be lazily constructed so that until accessed for the first time, will be null internally.

@:value(true)debugDraw:Bool = true

Set to disable debug drawing/

When true, this Constraint will not be drawn during debug draw operations unless specifically given as argument to Debug draw() method.

compound:Null<Compound>

Compound this Constraints belong to.

If this constraint is in a Space or another Compound and you change its compound, then it will be removed from that Space or Compound.

space:Null<Space>

Space this constraint is inside of.

Whether this constraint is directly in a Space, or part of a Compound which is inside of a space, this value will be equal to that Space.

If this constraint is inside of a Compound, then you cannot modify its Space as the constraint belongs to that Compound.

read onlyisSleeping:Bool

Whether this constraint is sleeping or not.

This property is only defined if the constraint is inside of a Space and is active, otherwise an error will be thrown should you access this property.

This value is immutable, In Nape you do not ever need to manually wake up a Constraint. It will always be done automatically without error.

To manually put a Constraint to sleep is against the very nature of Nape API and so is excluded from the core of Nape. If you really want to do this you should make use of the nape-hacks module.

active:Bool

Whether this constraint is active or not.

Setting a constraint to be no longer active is a useful way of temporarigly disabling a constraint without having to remove it from a Space.

ignore:Bool

Whether interactions between related Bodys will be ignored.

If true, then the Bodys related to this constraint will not be permitted to interact in anyway, including callbacks.

stiff:Bool

Whether constraint is stiff, or elastic.

A stiff constraint has its positional error resolved directly as with contact penetrations. This is generally a more stable way of solving positional errors but has a side-effect that for example changing the pivot point on a constraint used for mouse control will not cause the objects to swing as the positional error is solved without effecting the velocity of the object which may not be wanted.

If false, then the positional error of the constraint will be resolved in an elastic way using changes in velocity.

frequency:Float

Frequency of elastic properties of constraint.

This property only has an effect when constraint is not stiff.

This value corresponds to in an ideal situation, the number of spring like oscillations the constraint will make per second.

This value must be strictly positive (0 not allowed).

damping:Float

Damping ratio of elastic properties of constraint.

This property only has an effect when constraint is not stiff.

This value corresponds to in the ideal situation, the damping ratio of the constraints oscillations with 1 corresponding to a total dampening, and values greater than one being over-dampening.

This value must be zero or positive.

maxForce:Float

The maximum amount of force this constraint is allowed to use.

This value, whilst still used in a stiff constraint will not work as you might hope for; since a stiff constraint resolves positional error without using impulses, the maxForce will not have any effect on how positional errors are resolved.

This value must be zero or positive.

maxError:Float

The maximum amount of error this constraint is allowed to use.

For stiff constraints, this value only serves to work in conjunction with breakUnderError to permit breaking of the constraint.

For non-stiff constraints, this value will also effect how the constraint behaves when breakUnderError is false by restricting the amount of error that will be resolved; this will not work for stiff constraints.

breakUnderForce:Bool

Whether constraint will break once maxForce is reached.

This property effects both stiff and non-stiff constraints, though for the same reasons as those of maxForce, does not make much sense to be used in stiff constraints.

breakUnderError:Bool

Whether constraint will break once maxError is reached.

This property effects both stiff and non-stiff constraints.

removeOnBreak:Bool

Whether constraint will be removed when it breaks.

If true, then when constraint is broken it will be removed from the Space. Otherwise it will simple be made inactive.

read onlycbTypes:CbTypeList

Set of CbTypes for this constraints for callbacks.

This value cannot at present be set, but can be modified.

Inherited Methods

Defined by Constraint

@:keeptoString():String

@private

copy():Constraint

Produce copy of constraint.

All constraint properties except for internal impulse cache and userData field will be copied.

Returns:

The copied Constraint.