PlayRho  2.0.0
An interactive physics engine & library.
playrho::d2::DistanceJointConf Struct Reference

Distance joint definition. More...

#include <playrho/d2/DistanceJointConf.hpp>

Inheritance diagram for playrho::d2::DistanceJointConf:
[legend]
Collaboration diagram for playrho::d2::DistanceJointConf:
[legend]

Public Types

using super = JointBuilder< DistanceJointConf >
 Super type.
 
- Public Types inherited from playrho::d2::JointBuilder< DistanceJointConf >
using reference = value_type &
 Reference type.
 
using value_type = DistanceJointConf
 Value type.
 

Public Member Functions

constexpr DistanceJointConf () noexcept=default
 Default constructor.
 
 DistanceJointConf (BodyID bA, BodyID bB, const Length2 &laA=Length2{}, const Length2 &laB=Length2{}, Length l=1_m) noexcept
 Initializing constructor. More...
 
constexpr auto & UseDampingRatio (Real v) noexcept
 Uses the given damping ratio.
 
constexpr auto & UseFrequency (NonNegative< Frequency > v) noexcept
 Uses the given frequency.
 
constexpr auto & UseLength (Length v) noexcept
 Uses the given length. More...
 
- Public Member Functions inherited from playrho::d2::JointBuilder< DistanceJointConf >
constexpr reference UseBodyA (BodyID b) noexcept
 Use value for body A setting.
 
constexpr reference UseBodyB (BodyID b) noexcept
 Use value for body B setting.
 
constexpr reference UseCollideConnected (bool v) noexcept
 Use value for collide connected setting.
 

Public Attributes

LinearVelocity bias = {}
 Bias.
 
Real dampingRatio = 0
 Damping ratio. More...
 
NonNegative< Frequencyfrequency = DefaultFrequency
 Mass-spring-damper frequency. More...
 
Momentum impulse = 0_Ns
 Impulse.
 
InvMass invGamma = {}
 Inverse gamma.
 
Length length = 1_m
 Natural length between the anchor points.
 
Length2 localAnchorA = Length2{}
 Local anchor point relative to body A's origin.
 
Length2 localAnchorB = Length2{}
 Local anchor point relative to body B's origin.
 
Mass mass = 0_kg
 Mass.
 
Length2 rA = {}
 Relative A position.
 
Length2 rB = {}
 Relative B position.
 
UnitVec u
 "u" directional.
 
- Public Attributes inherited from playrho::d2::JointConf
BodyID bodyA = InvalidBodyID
 1st attached body.
 
BodyID bodyB = InvalidBodyID
 2nd attached body.
 
bool collideConnected = false
 Collide connected. More...
 

Static Public Attributes

static constexpr auto DefaultFrequency = NonNegativeFF<Frequency>(0_Hz)
 Default frequency.
 

Related Functions

(Note that these are not member functions.)

constexpr AngularMomentum GetAngularReaction (const DistanceJointConf &) noexcept
 Gets the current angular reaction for the given configuration.
 
constexpr auto GetLength (const DistanceJointConf &object) noexcept
 Free function for getting the length value of the given configuration.
 
constexpr Momentum2 GetLinearReaction (const DistanceJointConf &object) noexcept
 Gets the current linear reaction for the given configuration.
 
void InitVelocity (DistanceJointConf &object, const Span< BodyConstraint > &bodies, const StepConf &step, const ConstraintSolverConf &conf)
 Initializes velocity constraint data based on the given solver data. More...
 
constexpr void SetDampingRatio (DistanceJointConf &object, Real value) noexcept
 Free function for setting the damping ratio value of the given configuration.
 
constexpr void SetFrequency (DistanceJointConf &object, NonNegative< Frequency > value) noexcept
 Free function for setting the frequency value of the given configuration.
 
constexpr auto SetLength (DistanceJointConf &object, Length value) noexcept
 Free function for setting the length value of the given configuration.
 
constexpr bool ShiftOrigin (DistanceJointConf &, Length2) noexcept
 Shifts the origin notion of the given configuration.
 
bool SolvePosition (const DistanceJointConf &object, const Span< BodyConstraint > &bodies, const ConstraintSolverConf &conf)
 Solves the position constraint. More...
 
bool SolveVelocity (DistanceJointConf &object, const Span< BodyConstraint > &bodies, const StepConf &step)
 Solves velocity constraint. More...
 

Detailed Description

Distance joint definition.

This requires defining an anchor point on both bodies and the non-zero length of the distance joint. The definition uses local anchor points 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.
See also
Joint, World::CreateJoint

Constructor & Destructor Documentation

◆ DistanceJointConf()

playrho::d2::DistanceJointConf::DistanceJointConf ( BodyID  bA,
BodyID  bB,
const Length2 laA = Length2{},
const Length2 laB = Length2{},
Length  l = 1_m 
)
noexcept

Initializing constructor.

Initialize the bodies, anchors, and length using the world anchors.

Member Function Documentation

◆ UseLength()

constexpr auto& playrho::d2::DistanceJointConf::UseLength ( Length  v)
inlineconstexprnoexcept

Uses the given length.

Note
Manipulating the length when the frequency is zero can lead to non-physical behavior.

Friends And Related Function Documentation

◆ InitVelocity()

void InitVelocity ( DistanceJointConf object,
const Span< BodyConstraint > &  bodies,
const StepConf step,
const ConstraintSolverConf conf 
)
related

Initializes velocity constraint data based on the given solver data.

Note
This MUST be called prior to calling SolveVelocity.
Parameters
objectConfiguration object. bodyA and bodyB must index bodies within the given bodies container or be the special body ID value of InvalidBodyID.
bodiesContainer of body constraints.
stepConfiguration for the step.
confConstraint solver configuration.
Exceptions
std::out_of_rangeIf the given object's bodyA or bodyB values are not InvalidBodyID and are not indices within range of the given bodies container.
See also
SolveVelocity.

◆ SolvePosition()

bool SolvePosition ( const DistanceJointConf object,
const Span< BodyConstraint > &  bodies,
const ConstraintSolverConf conf 
)
related

Solves the position constraint.

Parameters
objectConfiguration object. bodyA and bodyB must index bodies within the given bodies container or be the special body ID value of InvalidBodyID.
bodiesContainer of body constraints.
confConstraint solver configuration.
Exceptions
std::out_of_rangeIf the given object's bodyA or bodyB values are not InvalidBodyID and are not indices within range of the given bodies container.
Returns
true if the position errors are within tolerance.

◆ SolveVelocity()

bool SolveVelocity ( DistanceJointConf object,
const Span< BodyConstraint > &  bodies,
const StepConf step 
)
related

Solves velocity constraint.

Precondition
InitVelocity has been called.
Parameters
objectConfiguration object. bodyA and bodyB must index bodies within the given bodies container or be the special body ID value of InvalidBodyID.
bodiesContainer of body constraints.
stepConfiguration for the step.
Exceptions
std::out_of_rangeIf the given object's bodyA or bodyB values are not InvalidBodyID and are not indices within range of the given bodies container.
See also
InitVelocity.
Returns
true if velocity is "solved", false otherwise.

Member Data Documentation

◆ dampingRatio

Real playrho::d2::DistanceJointConf::dampingRatio = 0

Damping ratio.

Note
0 = no damping, 1 = critical damping.

Referenced by UseDampingRatio().

◆ frequency

NonNegative<Frequency> playrho::d2::DistanceJointConf::frequency = DefaultFrequency

Mass-spring-damper frequency.

Note
0 disables softness.

Referenced by UseFrequency().


The documentation for this struct was generated from the following files: