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

Gear joint definition. More...

#include <playrho/d2/GearJointConf.hpp>

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

Classes

struct  PrismaticData
 Prismatic specific data. More...
 
struct  RevoluteData
 Revolute specific data. More...
 

Public Types

using super = JointBuilder< GearJointConf >
 Super type.
 
using TypeData = std::variant< std::monostate, PrismaticData, RevoluteData >
 Type specific data type alias.
 
- Public Types inherited from playrho::d2::JointBuilder< GearJointConf >
using reference = value_type &
 Reference type.
 
using value_type = GearJointConf
 Value type.
 

Public Member Functions

constexpr GearJointConf () noexcept=default
 Default constructor.
 
 GearJointConf (BodyID bA, BodyID bB, BodyID bC, BodyID bD) noexcept
 Initializing constructor.
 
constexpr auto & UseRatio (Real v) noexcept
 Uses the given ratio value.
 
- Public Member Functions inherited from playrho::d2::JointBuilder< GearJointConf >
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

BodyID bodyC = InvalidBodyID
 Identifier of body C.
 
BodyID bodyD = InvalidBodyID
 Identifier of body D.
 
Real constant = Real{0}
 Constant applied with the ratio. More...
 
Momentum impulse = 0_Ns
 Impulse.
 
Vec2 JvAC = {}
 A-C directional data.
 
Vec2 JvBD = {}
 B-D directional data.
 
Length JwA = 0_m
 Data for calculating Body A velocity.
 
Length JwB = 0_m
 Data for calculating Body B velocity.
 
Length JwC = 0_m
 Data for calculating Body C velocity.
 
Length JwD = 0_m
 Data for calculating Body D velocity.
 
Real mass = 0
 Either linear mass or angular mass.
 
Real ratio = Real{1}
 
TypeData typeDataAC
 Data for a revolute or prismatic joint between body A & C.
 
TypeData typeDataBD
 Data for a revolute or prismatic joint between body B & D.
 
- 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 AngularMomentum GetAngularReaction (const GearJointConf &object)
 Gets the current angular reaction for the given configuration.
 
constexpr auto GetConstant (const GearJointConf &object) noexcept
 Free function for getting the constant value of the given configuration.
 
constexpr Momentum2 GetLinearReaction (const GearJointConf &object)
 Gets the current linear reaction for the given configuration.
 
constexpr auto GetRatio (const GearJointConf &object) noexcept
 Free function for getting the ratio value of the given configuration.
 
TypeID GetTypeAC (const GearJointConf &object) noexcept
 Free function for getting joint 1 type value of the given configuration.
 
TypeID GetTypeBD (const GearJointConf &object) noexcept
 Free function for getting joint 2 type value of the given configuration.
 
void InitVelocity (GearJointConf &object, const Span< BodyConstraint > &bodies, const StepConf &step, const ConstraintSolverConf &conf)
 Initializes velocity constraint data based on the given solver data. More...
 
constexpr auto SetRatio (GearJointConf &object, Real value) noexcept
 Free function for setting the ratio value of the given configuration.
 
constexpr bool ShiftOrigin (GearJointConf &, const Length2 &) noexcept
 Shifts the origin notion of the given configuration.
 
bool SolvePosition (const GearJointConf &object, const Span< BodyConstraint > &bodies, const ConstraintSolverConf &conf)
 Solves the position constraint. More...
 
bool SolveVelocity (GearJointConf &object, const Span< BodyConstraint > &bodies, const StepConf &step)
 Solves velocity constraint. More...
 

Detailed Description

Gear joint definition.

A gear joint is used to connect two joints together. Either joint can be a revolute or prismatic joint. You specify a gear ratio to bind the motions together: coordinate1 + ratio * coordinate2 = constant. The ratio can be negative or positive. If one joint is a revolute joint and the other joint is a prismatic joint, then the ratio will have units of length or units of 1/length.

Warning
You have to manually destroy the gear joint if joint-1 or joint-2 is destroyed.
See also
Joint, World::CreateJoint

Friends And Related Function Documentation

◆ InitVelocity()

void InitVelocity ( GearJointConf 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 GearJointConf 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 ( GearJointConf 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

◆ constant

Real playrho::d2::GearJointConf::constant = Real{0}

Constant applied with the ratio.

Note
If this value is not finite, then position constraint solving will be skipped.
See also
ratio.

◆ ratio

Real playrho::d2::GearJointConf::ratio = Real{1}

The gear ratio.

See also
constant, GearJoint.

Referenced by UseRatio().


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