Table of Contents

Class DistanceJoint

Namespace
Alis.Core.Physic.Dynamics.Joints
Assembly
Alis.dll

A distance joint rains two points on two bodies to remain at a fixed distance from each other. You can view this as a massless, rigid rod.

public class DistanceJoint : Joint

Inheritance

Inherited Members

Remarks

1-D rained system m (v2 - v1) = lambda v2 + (beta/h) * x1 + gamma * lambda = 0, gamma has units of inverse mass. x2 = x1 + h * v2 1-D mass-damper-spring system m (v2 - v1) + h * d * v2 + h * k * C = norm(p2 - p1) - L u = (p2 - p1) / norm(p2 - p1) Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1)) J = [-u -cross(r1, u) u cross(r2, u)] K = J * invM * JT = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2

Constructors

DistanceJoint()

Initializes a new instance of the Alis.Core.Physic.Dynamics.Joints.DistanceJoint class

internal DistanceJoint()

DistanceJoint(Body, Body, Vector2, Vector2, bool)

This requires defining an anchor point on both bodies and the non-zero length of the distance joint. If you don't supply a length, the local anchor points is used so that the initial configuration can violate the constraint slightly. This helps when saving and loading a game. Warning Do not use a zero or short length.

public DistanceJoint(Body bodyA, Body bodyB, Vector2 anchorA, Vector2 anchorB, bool useWorldCoordinates = false)

Parameters

bodyA Body

The first body

bodyB Body

The second body

anchorA Vector2

The first body anchor

anchorB Vector2

The second body anchor

useWorldCoordinates bool

Set to true if you are using world coordinates as anchors.

Fields

_bias

The bias

private float _bias

Field Value

float

_gamma

The gamma

private float _gamma

Field Value

float

_impulse

The impulse

private float _impulse

Field Value

float

_indexA

The index

private int _indexA

Field Value

int

_indexB

The index

private int _indexB

Field Value

int

_invMassA

The inv mass

private float _invMassA

Field Value

float

_invMassB

The inv mass

private float _invMassB

Field Value

float

_localCenterA

The local center

private Vector2 _localCenterA

Field Value

Vector2

_localCenterB

The local center

private Vector2 _localCenterB

Field Value

Vector2

_mass

The mass

private float _mass

Field Value

float

_rA

The

private Vector2 _rA

Field Value

Vector2

_rB

The

private Vector2 _rB

Field Value

Vector2

_u

The

private Vector2 _u

Field Value

Vector2

invIa

The inv ia

private float invIa

Field Value

float

invIb

The inv ib

private float invIb

Field Value

float

Properties

DampingRatio

The damping ratio. 0 = no damping, 1 = critical damping.

public float DampingRatio { get; set; }

Property Value

float

Frequency

The mass-spring-damper frequency in Hertz. A value of 0 disables softness.

public float Frequency { get; set; }

Property Value

float

Length

The natural length between the anchor points. Manipulating the length can lead to non-physical behavior when the frequency is zero.

public float Length { get; set; }

Property Value

float

LocalAnchorA

The local anchor point relative to bodyA's origin.

public Vector2 LocalAnchorA { get; set; }

Property Value

Vector2

LocalAnchorB

The local anchor point relative to bodyB's origin.

public Vector2 LocalAnchorB { get; set; }

Property Value

Vector2

WorldAnchorA

Gets or sets the value of the world anchor a

public override sealed Vector2 WorldAnchorA { get; set; }

Property Value

Vector2

WorldAnchorB

Gets or sets the value of the world anchor b

public override sealed Vector2 WorldAnchorB { get; set; }

Property Value

Vector2

Methods

GetReactionForce(float)

Get the reaction force given the inverse time step. Unit is N.

public override Vector2 GetReactionForce(float invDt)

Parameters

invDt float

Returns

Vector2

GetReactionTorque(float)

Get the reaction torque given the inverse time step. Unit is N*m. This is always zero for a distance joint.

public override float GetReactionTorque(float invDt)

Parameters

invDt float

Returns

float

InitVelocityConstraints(ref SolverData)

Inits the velocity constraints using the specified data

internal override void InitVelocityConstraints(ref SolverData data)

Parameters

data SolverData

The data

SolvePositionConstraints(ref SolverData)

Describes whether this instance solve position constraints

internal override bool SolvePositionConstraints(ref SolverData data)

Parameters

data SolverData

The data

Returns

bool

The bool

SolveVelocityConstraints(ref SolverData)

Solves the velocity constraints using the specified data

internal override void SolveVelocityConstraints(ref SolverData data)

Parameters

data SolverData

The data