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

#include <RackAndPinionConstraintPart.h>

Public Member Functions

void CalculateConstraintProperties (const Body &inBody1, Vec3Arg inWorldSpaceHingeAxis, const Body &inBody2, Vec3Arg inWorldSpaceSliderAxis, float inRatio)
 
void Deactivate ()
 Deactivate this constraint. More...
 
bool IsActive () const
 Check if constraint is active. More...
 
void WarmStart (Body &ioBody1, Body &ioBody2, float inWarmStartImpulseRatio)
 
bool SolveVelocityConstraint (Body &ioBody1, Vec3Arg inWorldSpaceHingeAxis, Body &ioBody2, Vec3Arg inWorldSpaceSliderAxis, float inRatio)
 
float GetTotalLambda () const
 Return lagrange multiplier. More...
 
bool SolvePositionConstraint (Body &ioBody1, Body &ioBody2, float inC, float inBaumgarte) const
 
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

Constraint that constrains a rotation to a translation

Constraint equation:

C = Theta(t) - r d(t)

Derivative:

d/dt C = 0 <=> w1 . a - r v2 . b = 0

Jacobian:

\[J = \begin{bmatrix}0 & a^T & -r b^T & 0\end{bmatrix}\]

Used terms (here and below, everything in world space):
a = axis around which body 1 rotates (normalized).
b = axis along which body 2 slides (normalized).
Theta(t) = rotation around a of body 1.
d(t) = distance body 2 slides.
r = ratio between rotation and translation.
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.
\(\beta\) = baumgarte constant.

Member Function Documentation

◆ CalculateConstraintProperties()

void RackAndPinionConstraintPart::CalculateConstraintProperties ( const Body inBody1,
Vec3Arg  inWorldSpaceHingeAxis,
const Body inBody2,
Vec3Arg  inWorldSpaceSliderAxis,
float  inRatio 
)
inline

Calculate properties used during the functions below

Parameters
inBody1The first body that this constraint is attached to
inBody2The second body that this constraint is attached to
inWorldSpaceHingeAxisThe axis around which body 1 rotates
inWorldSpaceSliderAxisThe axis along which body 2 slides
inRatioThe ratio between rotation and translation

◆ Deactivate()

void RackAndPinionConstraintPart::Deactivate ( )
inline

Deactivate this constraint.

◆ GetTotalLambda()

float RackAndPinionConstraintPart::GetTotalLambda ( ) const
inline

Return lagrange multiplier.

◆ IsActive()

bool RackAndPinionConstraintPart::IsActive ( ) const
inline

Check if constraint is active.

◆ RestoreState()

void RackAndPinionConstraintPart::RestoreState ( StateRecorder inStream)
inline

Restore state of this constraint part.

◆ SaveState()

void RackAndPinionConstraintPart::SaveState ( StateRecorder inStream) const
inline

Save state of this constraint part.

◆ SolvePositionConstraint()

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

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

Parameters
ioBody1The first body that this constraint is attached to
ioBody2The second body that this constraint is attached to
inCValue of the constraint equation (C)
inBaumgarteBaumgarte constant (fraction of the error to correct)

◆ SolveVelocityConstraint()

bool RackAndPinionConstraintPart::SolveVelocityConstraint ( Body ioBody1,
Vec3Arg  inWorldSpaceHingeAxis,
Body ioBody2,
Vec3Arg  inWorldSpaceSliderAxis,
float  inRatio 
)
inline

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

Parameters
ioBody1The first body that this constraint is attached to
ioBody2The second body that this constraint is attached to
inWorldSpaceHingeAxisThe axis around which body 1 rotates
inWorldSpaceSliderAxisThe axis along which body 2 slides
inRatioThe ratio between rotation and translation

◆ WarmStart()

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

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

Parameters
ioBody1The first body that this constraint is attached to
ioBody2The second body that this constraint is attached to
inWarmStartImpulseRatioRatio of new step to old time step (dt_new / dt_old) for scaling the lagrange multiplier of the previous frame

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