Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
DualAxisConstraintPart Class Reference

#include <DualAxisConstraintPart.h>

Public Types

using Vec2 = Vector< 2 >
 
using Mat22 = Matrix< 2, 2 >
 

Public Member Functions

void CalculateConstraintProperties (const Body &inBody1, Mat44Arg inRotation1, Vec3Arg inR1PlusU, const Body &inBody2, Mat44Arg inRotation2, Vec3Arg inR2, Vec3Arg inN1, Vec3Arg inN2)
 
void Deactivate ()
 Deactivate this constraint. More...
 
bool IsActive () const
 Check if constraint is active. More...
 
void WarmStart (Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2, float inWarmStartImpulseRatio)
 
bool SolveVelocityConstraint (Body &ioBody1, Body &ioBody2, Vec3Arg inN1, Vec3Arg inN2)
 
bool SolvePositionConstraint (Body &ioBody1, Body &ioBody2, Vec3Arg inU, Vec3Arg inN1, Vec3Arg inN2, float inBaumgarte) const
 
void SetTotalLambda (const Vec2 &inLambda)
 Override total lagrange multiplier, can be used to set the initial value for warm starting. More...
 
const Vec2GetTotalLambda () const
 Return lagrange multiplier. More...
 
void SaveState (StateRecorder &inStream) const
 Save state of this constraint part. More...
 
void RestoreState (StateRecorder &inStream)
 Restore state of this constraint part. More...
 

Detailed Description

Constrains movement on 2 axis

See also
"Constraints Derivation for Rigid Body Simulation in 3D" - Daniel Chappuis, section 2.3.1

Constraint equation (eq 51):

\[C = \begin{bmatrix} (p_2 - p_1) \cdot n_1 \\ (p_2 - p_1) \cdot n_2\end{bmatrix}\]

Jacobian (transposed) (eq 55):

\[J^T = \begin{bmatrix} -n_1 & -n_2 \\ -(r_1 + u) \times n_1 & -(r_1 + u) \times n_2 \\ n_1 & n_2 \\ r_2 \times n_1 & r_2 \times n_2 \end{bmatrix}\]

Used terms (here and below, everything in world space):
n1, n2 = constraint axis (normalized).
p1, p2 = constraint points.
r1 = p1 - x1.
r2 = p2 - x2.
u = x2 + r2 - x1 - r1 = p2 - p1.
x1, x2 = center of mass for the bodies.
v = [v1, w1, v2, w2].
v1, v2 = linear velocity of body 1 and 2.
w1, w2 = angular velocity of body 1 and 2.
M = mass matrix, a diagonal matrix of the mass and inertia with diagonal [m1, I1, m2, I2].
\(K^{-1} = \left( J M^{-1} J^T \right)^{-1}\) = effective mass.
b = velocity bias.
\(\beta\) = baumgarte constant.

Member Typedef Documentation

◆ Mat22

◆ Vec2

Member Function Documentation

◆ CalculateConstraintProperties()

void DualAxisConstraintPart::CalculateConstraintProperties ( const Body inBody1,
Mat44Arg  inRotation1,
Vec3Arg  inR1PlusU,
const Body inBody2,
Mat44Arg  inRotation2,
Vec3Arg  inR2,
Vec3Arg  inN1,
Vec3Arg  inN2 
)
inline

Calculate properties used during the functions below All input vectors are in world space

◆ Deactivate()

void DualAxisConstraintPart::Deactivate ( )
inline

Deactivate this constraint.

◆ GetTotalLambda()

const Vec2 & DualAxisConstraintPart::GetTotalLambda ( ) const
inline

Return lagrange multiplier.

◆ IsActive()

bool DualAxisConstraintPart::IsActive ( ) const
inline

Check if constraint is active.

◆ RestoreState()

void DualAxisConstraintPart::RestoreState ( StateRecorder inStream)
inline

Restore state of this constraint part.

◆ SaveState()

void DualAxisConstraintPart::SaveState ( StateRecorder inStream) const
inline

Save state of this constraint part.

◆ SetTotalLambda()

void DualAxisConstraintPart::SetTotalLambda ( const Vec2 inLambda)
inline

Override total lagrange multiplier, can be used to set the initial value for warm starting.

◆ SolvePositionConstraint()

bool DualAxisConstraintPart::SolvePositionConstraint ( Body ioBody1,
Body ioBody2,
Vec3Arg  inU,
Vec3Arg  inN1,
Vec3Arg  inN2,
float  inBaumgarte 
) const
inline

Iteratively update the position constraint. Makes sure C(...) = 0. All input vectors are in world space

◆ SolveVelocityConstraint()

bool DualAxisConstraintPart::SolveVelocityConstraint ( Body ioBody1,
Body ioBody2,
Vec3Arg  inN1,
Vec3Arg  inN2 
)
inline

Iteratively update the velocity constraint. Makes sure d/dt C(...) = 0, where C is the constraint equation. All input vectors are in world space

◆ WarmStart()

void DualAxisConstraintPart::WarmStart ( Body ioBody1,
Body ioBody2,
Vec3Arg  inN1,
Vec3Arg  inN2,
float  inWarmStartImpulseRatio 
)
inline

Must be called from the WarmStartVelocityConstraint call to apply the previous frame's impulses All input vectors are in world space


The documentation for this class was generated from the following file: