nape.constraint.LineJoint

type
class
extends
Constraint
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 nstead 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

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)
+ Construct a new LineJoint.

Instance Properties hide inherited show inherited

var active : Bool = true

+ Whether this constraint is active or not.

var anchor1 : nape.geom.Vec2

+ Anchor point on first Body, defining position on line.

var anchor2 : nape.geom.Vec2

+ Anchor point on second Body.

var body1 : Null<nape.phys.Body>

+ First Body in constraint, defining the line segment.

var body2 : Null<nape.phys.Body>

+ Second Body in constraint.

var breakUnderError : Bool = false

+ Whether constraint will break once maxError is reached.

var breakUnderForce : Bool = false

+ Whether constraint will break once maxForce is reached.

readonly var cbTypes : nape.callbacks.CbTypeList = [CbType.ANY_CONSTRAINT]

+ Set of CbTypes for this constraints for callbacks.

var compound : Null<nape.phys.Compound> = null

+ Compound this Constraints belong to.

var damping : Float = 1

+ Damping ratio of elastic properties of constraint.

var debugDraw : Bool = true

+ Set to disable debug drawing/

var direction : nape.geom.Vec2

+ Direction of line on first Body.

var frequency : Float = 10

+ Frequency of elastic properties of constraint.

var ignore : Bool = false

+ Whether interactions between related Bodys will be ignored.

readonly var isSleeping : Bool

+ Whether this constraint is sleeping or not.

var jointMax : Float

+ Upper bound for constraint.

var jointMin : Float

+ Lower bound for constraint.

var maxError : Float = infinity

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

var maxForce : Float = infinity

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

var removeOnBreak : Bool = true

+ Whether constraint will be removed when it breaks.

var space : Null<nape.space.Space> = null

+ Space this constraint is inside of.

var stiff : Bool = true

+ Whether constraint is stiff, or elastic.

readonly var userData : Dynamic<Dynamic> = {}

+ Dynamic object for user to store additional data.

Instance Methods hide inherited show inherited

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

+ Compute impulse that was applied to the given Body.

copy():Constraint

+ Produce copy of constraint.

function impulse():nape.geom.MatMN

+ Return the constraint-space impulse applied in previous step.

function visitBodies(lambda:nape.phys.Body -> Void):Void

+ Apply given function to all Bodys linked to the constraint.