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

Wheel joint definition. More...

#include <WheelJointConf.hpp>

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

Public Types

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

Public Member Functions

constexpr WheelJointConf ()=default
 Default constructor.
 
 WheelJointConf (BodyID bA, BodyID bB, Length2 laA=Length2{}, Length2 laB=Length2{}, UnitVec axis=UnitVec::GetRight()) noexcept
 Initialize the bodies, anchors, axis, and reference angle using the world anchor and world axis.
 
constexpr auto & UseEnableMotor (bool v) noexcept
 Uses the given enable motor state value.
 
constexpr auto & UseMaxMotorTorque (Torque v) noexcept
 Uses the given max motor toque value.
 
constexpr auto & UseMotorSpeed (AngularVelocity v) noexcept
 Uses the given motor speed value.
 
constexpr auto & UseFrequency (NonNegative< Frequency > v) noexcept
 Uses the given frequency value.
 
constexpr auto & UseDampingRatio (Real v) noexcept
 Uses the given damping ratio value.
 
- Public Member Functions inherited from playrho::d2::JointBuilder< WheelJointConf >
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{}
 The local anchor point relative to body A's origin.
 
Length2 localAnchorB = Length2{}
 The local anchor point relative to body B's origin.
 
UnitVec localXAxisA = UnitVec::GetRight()
 The local X translation axis in body-A.
 
UnitVec localYAxisA = GetRevPerpendicular(UnitVec::GetRight())
 The local Y translation axis in body-A.
 
bool enableMotor = false
 Enable/disable the joint motor.
 
Torque maxMotorTorque = Torque{0}
 The maximum motor torque.
 
AngularVelocity motorSpeed = 0_rpm
 The desired angular motor speed.
 
NonNegative< Frequencyfrequency = 2_Hz
 Suspension frequency, zero indicates no suspension.
 
Real dampingRatio = 0.7f
 Suspension damping ratio, one indicates critical damping.
 
Momentum impulse = 0
 Impulse.
 
AngularMomentum angularImpulse = 0
 Angular impulse.
 
Momentum springImpulse = 0
 Spring impulse.
 
UnitVec ax
 Solver A X directional.
 
UnitVec ay
 Solver A Y directional.
 
Length sAx = 0_m
 Solver A x location.
 
Length sBx = 0_m
 Solver B x location.
 
Length sAy = 0_m
 Solver A y location.
 
Length sBy = 0_m
 Solver B y location.
 
Mass mass = 0_kg
 Mass.
 
RotInertia angularMass = RotInertia{0}
 Motor mass.
 
Mass springMass = 0_kg
 Spring mass.
 
LinearVelocity bias = 0_mps
 Bias.
 
InvMass gamma = InvMass{0}
 Gamma.
 
- 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 WheelJointConf &object)
 Gets the current linear reaction for the given configuration.
 
constexpr auto ShiftOrigin (WheelJointConf &, Length2)
 Shifts the origin notion of the given configuration.
 
void InitVelocity (WheelJointConf &object, std::vector< BodyConstraint > &bodies, const StepConf &step, const ConstraintSolverConf &conf)
 Initializes velocity constraint data based on the given solver data. More...
 
bool SolveVelocity (WheelJointConf &object, std::vector< BodyConstraint > &bodies, const StepConf &step)
 Solves velocity constraint. More...
 
bool SolvePosition (const WheelJointConf &object, std::vector< BodyConstraint > &bodies, const ConstraintSolverConf &conf)
 Solves the position constraint. More...
 
constexpr void SetMaxMotorTorque (WheelJointConf &object, Torque value) noexcept
 Sets the maximum motor torque for the given configuration.
 
constexpr void SetFrequency (WheelJointConf &object, NonNegative< Frequency > value) noexcept
 Free function for setting the frequency of the given configuration.
 
constexpr void SetDampingRatio (WheelJointConf &object, Real value) noexcept
 Free function for setting the damping ratio of the given configuration.
 

Detailed Description

Wheel joint definition.

This joint provides two degrees of freedom: translation along an axis fixed in body A and rotation in the plane. In other words, it is a point to line constraint with a rotational motor and a linear spring/damper. This requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game.

Note
This joint is designed for vehicle suspensions.
See also
Joint, World::CreateJoint
Examples
Joint.cpp, WheelJoint.cpp, and World.cpp.

Friends And Related Function Documentation

◆ InitVelocity()

void InitVelocity ( WheelJointConf 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 WheelJointConf 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 ( WheelJointConf 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.

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