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

#include <HingeRotationConstraintPart.h>

Public Types

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

Public Member Functions

void CalculateConstraintProperties (const Body &inBody1, Mat44Arg inRotation1, Vec3Arg inWorldSpaceHingeAxis1, const Body &inBody2, Mat44Arg inRotation2, Vec3Arg inWorldSpaceHingeAxis2)
 Calculate properties used during the functions below. More...
 
void Deactivate ()
 Deactivate this constraint. More...
 
void WarmStart (Body &ioBody1, Body &ioBody2, float inWarmStartImpulseRatio)
 Must be called from the WarmStartVelocityConstraint call to apply the previous frame's impulses. More...
 
bool SolveVelocityConstraint (Body &ioBody1, Body &ioBody2)
 Iteratively update the velocity constraint. Makes sure d/dt C(...) = 0, where C is the constraint equation. More...
 
bool SolvePositionConstraint (Body &ioBody1, Body &ioBody2, float inBaumgarte) const
 Iteratively update the position constraint. Makes sure C(...) = 0. 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 rotation around 2 axis so that it only allows rotation around 1 axis

Based on: "Constraints Derivation for Rigid Body Simulation in 3D" - Daniel Chappuis, section 2.4.1

Constraint equation (eq 87):

\[C = \begin{bmatrix}a_1 \cdot b_2 \\ a_1 \cdot c_2\end{bmatrix}\]

Jacobian (eq 90):

\[J = \begin{bmatrix} 0 & -b_2 \times a_1 & 0 & b_2 \times a_1 \\ 0 & -c_2 \times a_1 & 0 & c2 \times a_1 \end{bmatrix}\]

Used terms (here and below, everything in world space):
a1 = hinge axis on body 1.
b2, c2 = axis perpendicular to hinge axis on body 2.
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.
E = identity matrix.

Member Typedef Documentation

◆ Mat22

◆ Vec2

Member Function Documentation

◆ CalculateConstraintProperties()

void HingeRotationConstraintPart::CalculateConstraintProperties ( const Body inBody1,
Mat44Arg  inRotation1,
Vec3Arg  inWorldSpaceHingeAxis1,
const Body inBody2,
Mat44Arg  inRotation2,
Vec3Arg  inWorldSpaceHingeAxis2 
)
inline

Calculate properties used during the functions below.

◆ Deactivate()

void HingeRotationConstraintPart::Deactivate ( )
inline

Deactivate this constraint.

◆ GetTotalLambda()

const Vec2 & HingeRotationConstraintPart::GetTotalLambda ( ) const
inline

Return lagrange multiplier.

◆ RestoreState()

void HingeRotationConstraintPart::RestoreState ( StateRecorder inStream)
inline

Restore state of this constraint part.

◆ SaveState()

void HingeRotationConstraintPart::SaveState ( StateRecorder inStream) const
inline

Save state of this constraint part.

◆ SolvePositionConstraint()

bool HingeRotationConstraintPart::SolvePositionConstraint ( Body ioBody1,
Body ioBody2,
float  inBaumgarte 
) const
inline

Iteratively update the position constraint. Makes sure C(...) = 0.

◆ SolveVelocityConstraint()

bool HingeRotationConstraintPart::SolveVelocityConstraint ( Body ioBody1,
Body ioBody2 
)
inline

Iteratively update the velocity constraint. Makes sure d/dt C(...) = 0, where C is the constraint equation.

◆ WarmStart()

void HingeRotationConstraintPart::WarmStart ( Body ioBody1,
Body ioBody2,
float  inWarmStartImpulseRatio 
)
inline

Must be called from the WarmStartVelocityConstraint call to apply the previous frame's impulses.


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