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
_gamma
The gamma
private float _gamma
Field Value
_impulse
The impulse
private float _impulse
Field Value
_indexA
The index
private int _indexA
Field Value
_indexB
The index
private int _indexB
Field Value
_invMassA
The inv mass
private float _invMassA
Field Value
_invMassB
The inv mass
private float _invMassB
Field Value
_localCenterA
The local center
private Vector2 _localCenterA
Field Value
_localCenterB
The local center
private Vector2 _localCenterB
Field Value
_mass
The mass
private float _mass
Field Value
_rA
The
private Vector2 _rA
Field Value
_rB
The
private Vector2 _rB
Field Value
_u
The
private Vector2 _u
Field Value
invIa
The inv ia
private float invIa
Field Value
invIb
The inv ib
private float invIb
Field Value
Properties
DampingRatio
The damping ratio. 0 = no damping, 1 = critical damping.
public float DampingRatio { get; set; }
Property Value
Frequency
The mass-spring-damper frequency in Hertz. A value of 0 disables softness.
public float Frequency { get; set; }
Property Value
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
LocalAnchorA
The local anchor point relative to bodyA's origin.
public Vector2 LocalAnchorA { get; set; }
Property Value
LocalAnchorB
The local anchor point relative to bodyB's origin.
public Vector2 LocalAnchorB { get; set; }
Property Value
WorldAnchorA
Gets or sets the value of the world anchor a
public override sealed Vector2 WorldAnchorA { get; set; }
Property Value
WorldAnchorB
Gets or sets the value of the world anchor b
public override sealed Vector2 WorldAnchorB { get; set; }
Property Value
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
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
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