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 : JointInheritance
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
bodyABody-
The first body
bodyBBody-
The second body
anchorAVector2-
The first body anchor
anchorBVector2-
The second body anchor
useWorldCoordinatesbool-
Set to true if you are using world coordinates as anchors.
Fields
_bias
The bias
private float _biasField Value
_gamma
The gamma
private float _gammaField Value
_impulse
The impulse
private float _impulseField Value
_indexA
The index
private int _indexAField Value
_indexB
The index
private int _indexBField Value
_invMassA
The inv mass
private float _invMassAField Value
_invMassB
The inv mass
private float _invMassBField Value
_localCenterA
The local center
private Vector2 _localCenterAField Value
_localCenterB
The local center
private Vector2 _localCenterBField Value
_mass
The mass
private float _massField Value
_rA
The
private Vector2 _rAField Value
_rB
The
private Vector2 _rBField Value
_u
The
private Vector2 _uField Value
invIa
The inv ia
private float invIaField Value
invIb
The inv ib
private float invIbField 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
invDtfloat
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
invDtfloat
Returns
InitVelocityConstraints(ref SolverData)
Inits the velocity constraints using the specified data
internal override void InitVelocityConstraints(ref SolverData data)Parameters
dataSolverData-
The data
SolvePositionConstraints(ref SolverData)
Describes whether this instance solve position constraints
internal override bool SolvePositionConstraints(ref SolverData data)Parameters
dataSolverData-
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
dataSolverData-
The data