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

#include <AngleConstraintPart.h>

Public Member Functions

void CalculateConstraintProperties (const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias=0.0f)
 
void CalculateConstraintPropertiesWithFrequencyAndDamping (float inDeltaTime, const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, float inFrequency, float inDamping)
 
void CalculateConstraintPropertiesWithStiffnessAndDamping (float inDeltaTime, const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, float inStiffness, float inDamping)
 
void CalculateConstraintPropertiesWithSettings (float inDeltaTime, const Body &inBody1, const Body &inBody2, Vec3Arg inWorldSpaceAxis, float inBias, float inC, const SpringSettings &inSpringSettings)
 Selects one of the above functions based on the spring settings.
 
void Deactivate ()
 Deactivate this constraint.
 
bool IsActive () const
 Check if constraint is active.
 
void WarmStart (Body &ioBody1, Body &ioBody2, float inWarmStartImpulseRatio)
 
bool SolveVelocityConstraint (Body &ioBody1, Body &ioBody2, Vec3Arg inWorldSpaceAxis, float inMinLambda, float inMaxLambda)
 
float GetTotalLambda () const
 Return lagrange multiplier.
 
bool SolvePositionConstraint (Body &ioBody1, Body &ioBody2, float inC, float inBaumgarte) const
 
void SaveState (StateRecorder &inStream) const
 Save state of this constraint part.
 
void RestoreState (StateRecorder &inStream)
 Restore state of this constraint part.
 

Detailed Description

Constraint that constrains rotation along 1 axis

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

Constraint equation (eq 108):

\[C = \theta(t) - \theta_{min}\]

Jacobian (eq 109):

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

Used terms (here and below, everything in world space):
a = axis around which rotation is constrained (normalized).
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 Function Documentation

◆ CalculateConstraintProperties()

void AngleConstraintPart::CalculateConstraintProperties ( const Body inBody1,
const Body inBody2,
Vec3Arg  inWorldSpaceAxis,
float  inBias = 0.0f 
)
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
inWorldSpaceAxisThe axis of rotation along which the constraint acts (normalized) Set the following terms to zero if you don't want to drive the constraint to zero with a spring:
inBiasBias term (b) for the constraint impulse: lambda = J v + b

◆ CalculateConstraintPropertiesWithFrequencyAndDamping()

void AngleConstraintPart::CalculateConstraintPropertiesWithFrequencyAndDamping ( float  inDeltaTime,
const Body inBody1,
const Body inBody2,
Vec3Arg  inWorldSpaceAxis,
float  inBias,
float  inC,
float  inFrequency,
float  inDamping 
)
inline

Calculate properties used during the functions below

Parameters
inDeltaTimeTime step
inBody1The first body that this constraint is attached to
inBody2The second body that this constraint is attached to
inWorldSpaceAxisThe axis of rotation along which the constraint acts (normalized) Set the following terms to zero if you don't want to drive the constraint to zero with a spring:
inBiasBias term (b) for the constraint impulse: lambda = J v + b
inCValue of the constraint equation (C)
inFrequencyOscillation frequency (Hz)
inDampingDamping factor (0 = no damping, 1 = critical damping)

◆ CalculateConstraintPropertiesWithSettings()

void AngleConstraintPart::CalculateConstraintPropertiesWithSettings ( float  inDeltaTime,
const Body inBody1,
const Body inBody2,
Vec3Arg  inWorldSpaceAxis,
float  inBias,
float  inC,
const SpringSettings inSpringSettings 
)
inline

Selects one of the above functions based on the spring settings.

◆ CalculateConstraintPropertiesWithStiffnessAndDamping()

void AngleConstraintPart::CalculateConstraintPropertiesWithStiffnessAndDamping ( float  inDeltaTime,
const Body inBody1,
const Body inBody2,
Vec3Arg  inWorldSpaceAxis,
float  inBias,
float  inC,
float  inStiffness,
float  inDamping 
)
inline

Calculate properties used during the functions below

Parameters
inDeltaTimeTime step
inBody1The first body that this constraint is attached to
inBody2The second body that this constraint is attached to
inWorldSpaceAxisThe axis of rotation along which the constraint acts (normalized) Set the following terms to zero if you don't want to drive the constraint to zero with a spring:
inBiasBias term (b) for the constraint impulse: lambda = J v + b
inCValue of the constraint equation (C)
inStiffnessSpring stiffness k.
inDampingSpring damping coefficient c.

◆ Deactivate()

void AngleConstraintPart::Deactivate ( )
inline

Deactivate this constraint.

◆ GetTotalLambda()

float AngleConstraintPart::GetTotalLambda ( ) const
inline

Return lagrange multiplier.

◆ IsActive()

bool AngleConstraintPart::IsActive ( ) const
inline

Check if constraint is active.

◆ RestoreState()

void AngleConstraintPart::RestoreState ( StateRecorder inStream)
inline

Restore state of this constraint part.

◆ SaveState()

void AngleConstraintPart::SaveState ( StateRecorder inStream) const
inline

Save state of this constraint part.

◆ SolvePositionConstraint()

bool AngleConstraintPart::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 AngleConstraintPart::SolveVelocityConstraint ( Body ioBody1,
Body ioBody2,
Vec3Arg  inWorldSpaceAxis,
float  inMinLambda,
float  inMaxLambda 
)
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
inWorldSpaceAxisThe axis of rotation along which the constraint acts (normalized)
inMinLambdaMinimum angular impulse to apply (N m s)
inMaxLambdaMaximum angular impulse to apply (N m s)

◆ WarmStart()

void AngleConstraintPart::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: