PlayRho  1.1.0
An Interactive Real-Time-Oriented C++ Physics Engine & Library
playrho::d2::DistanceJointConf Struct Reference

Distance joint definition. More...

#include <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 value_type = DistanceJointConf
 Value type.
 
using reference = value_type &
 Reference type.
 

Public Member Functions

constexpr DistanceJointConf ()=default
 Default constructor.
 
 DistanceJointConf (const DistanceJointConf &copy)=default
 Copy constructor.
 
 DistanceJointConf (BodyID bA, BodyID bB, Length2 laA=Length2{}, Length2 laB=Length2{}, Length l=1_m) noexcept
 Initializing constructor. More...
 
constexpr auto & UseLength (Length v) noexcept
 Uses the given length. More...
 
constexpr auto & UseFrequency (NonNegative< Frequency > v) noexcept
 Uses the given frequency.
 
constexpr auto & UseDampingRatio (Real v) noexcept
 Uses the given damping ratio.
 
- 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

Length2 localAnchorA = Length2{}
 Local anchor point relative to body A's origin. More...
 
Length2 localAnchorB = Length2{}
 Local anchor point relative to body B's origin. More...
 
Length length = 1_m
 Natural length between the anchor points. More...
 
NonNegative< Frequencyfrequency {}
 Mass-spring-damper frequency. More...
 
Real dampingRatio = 0
 Damping ratio. More...
 
Momentum impulse = 0_Ns
 Impulse. 4-bytes (with 4-byte Real).
 
UnitVec u
 "u" directional. 8-bytes (with 4-byte Real).
 
Length2 rA = {}
 Relative A position. 8-bytes (with 4-byte Real).
 
Length2 rB = {}
 Relative B position. 8-bytes (with 4-byte Real).
 
InvMass invGamma = {}
 Inverse gamma. 4-bytes (with 4-byte Real).
 
LinearVelocity bias = {}
 Bias. 4-bytes (with 4-byte Real).
 
Mass mass = 0_kg
 Mass. 4-bytes (with 4-byte Real).
 
- 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...
 

Related Functions

(Note that these are not member functions.)

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

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
Examples
DistanceJoint.cpp, GearJoint.cpp, and World.cpp.

Constructor & Destructor Documentation

◆ DistanceJointConf()

playrho::d2::DistanceJointConf::DistanceJointConf ( BodyID  bA,
BodyID  bB,
Length2  laA = Length2{},
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.
Examples
DistanceJoint.cpp.

Friends And Related Function Documentation

◆ InitVelocity()

void InitVelocity ( DistanceJointConf object,
std::vector< 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.
See also
SolveVelocity.

◆ SolvePosition()

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

Solves the position constraint.

Returns
true if the position errors are within tolerance.

◆ SolveVelocity()

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

Solves velocity constraint.

Precondition
InitVelocity has been called.
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.
4-bytes (with 4-byte Real).
Examples
DistanceJoint.cpp.

Referenced by UseDampingRatio().

◆ frequency

NonNegative<Frequency> playrho::d2::DistanceJointConf::frequency {}

Mass-spring-damper frequency.

Note
0 disables softness.
4-bytes (with 4-byte Real).
Examples
DistanceJoint.cpp.

Referenced by UseFrequency().

◆ length

Length playrho::d2::DistanceJointConf::length = 1_m

Natural length between the anchor points.

Note
4-bytes (with 4-byte Real).
Examples
DistanceJoint.cpp.

Referenced by UseLength().

◆ localAnchorA

Length2 playrho::d2::DistanceJointConf::localAnchorA = Length2{}

Local anchor point relative to body A's origin.

Note
8-bytes (with 4-byte Real).
Examples
DistanceJoint.cpp.

◆ localAnchorB

Length2 playrho::d2::DistanceJointConf::localAnchorB = Length2{}

Local anchor point relative to body B's origin.

Note
8-bytes (with 4-byte Real).
Examples
DistanceJoint.cpp.

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