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

Revolute joint definition. More...

#include <RevoluteJointConf.hpp>

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

Public Types

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

Public Member Functions

constexpr RevoluteJointConf ()=default
 Default constructor.
 
 RevoluteJointConf (BodyID bA, BodyID bB, Length2 laA=Length2{}, Length2 laB=Length2{}, Angle ra=0_deg) noexcept
 Initialize the bodies, anchors, and reference angle using a world anchor point.
 
constexpr auto & UseEnableLimit (bool v) noexcept
 Uses the given enable limit state value.
 
constexpr auto & UseLowerAngle (Angle v) noexcept
 Uses the given lower angle value.
 
constexpr auto & UseUpperAngle (Angle v) noexcept
 Uses the given upper angle value.
 
constexpr auto & UseEnableMotor (bool v) noexcept
 Uses the given enable motor state value.
 
constexpr auto & UseMotorSpeed (AngularVelocity v) noexcept
 Uses the given motor speed value.
 
constexpr auto & UseMaxMotorTorque (Torque v) noexcept
 Uses the given max motor torque value.
 
- Public Member Functions inherited from playrho::d2::JointBuilder< RevoluteJointConf >
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.
 
Length2 localAnchorB = Length2{}
 Local anchor point relative to body B's origin.
 
Vec3 impulse = Vec3{}
 Impulse. More...
 
AngularMomentum angularMotorImpulse = {}
 Motor impulse. More...
 
Angle referenceAngle = 0_deg
 Reference angle. More...
 
bool enableLimit = false
 Flag to enable joint limits.
 
Angle lowerAngle = 0_deg
 Lower angle for the joint limit.
 
Angle upperAngle = 0_deg
 Upper angle for the joint limit.
 
bool enableMotor = false
 Flag to enable the joint motor.
 
AngularVelocity motorSpeed = 0_rpm
 Desired motor speed.
 
Torque maxMotorTorque = 0
 Maximum motor torque used to achieve the desired motor speed.
 
Length2 rA = {}
 Rotated delta of body A's local center from local anchor A.
 
Length2 rB = {}
 Rotated delta of body B's local center from local anchor B.
 
Mat33 mass = {}
 Effective mass for point-to-point constraint.
 
RotInertia angularMass = {}
 Effective mass for motor/limit angular constraint.
 
LimitState limitState = LimitState::e_inactiveLimit
 Limit state.
 
- 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 auto ShiftOrigin (RevoluteJointConf &, Length2) noexcept
 Shifts the origin notion of the given configuration.
 
constexpr Angle GetAngularLowerLimit (const RevoluteJointConf &conf) noexcept
 Free function for getting the angular lower limit value of the given configuration.
 
constexpr Angle GetAngularUpperLimit (const RevoluteJointConf &conf) noexcept
 Free function for getting the angular upper limit value of the given configuration.
 
constexpr Momentum2 GetLinearReaction (const RevoluteJointConf &conf) noexcept
 Gets the current linear reaction of the given configuration.
 
constexpr AngularMomentum GetAngularReaction (const RevoluteJointConf &conf) noexcept
 Gets the current angular reaction of the given configuration.
 
void InitVelocity (RevoluteJointConf &object, std::vector< BodyConstraint > &bodies, const StepConf &step, const ConstraintSolverConf &conf)
 Initializes velocity constraint data based on the given solver data. More...
 
bool SolveVelocity (RevoluteJointConf &object, std::vector< BodyConstraint > &bodies, const StepConf &step)
 Solves velocity constraint. More...
 
bool SolvePosition (const RevoluteJointConf &object, std::vector< BodyConstraint > &bodies, const ConstraintSolverConf &conf)
 Solves the position constraint. More...
 
constexpr void SetAngularLimits (RevoluteJointConf &object, Angle lower, Angle upper) noexcept
 Free function for setting the angular limits of the given configuration.
 
constexpr void SetMaxMotorTorque (RevoluteJointConf &object, Torque value)
 Free function for setting the max motor torque of the given configuration.
 

Detailed Description

Revolute joint definition.

A revolute joint constrains two bodies to share a common point while they are free to rotate about the point. The relative rotation about the shared point is the joint angle. This requires defining an anchor point where the bodies are joined. The definition uses local anchor points so that the initial configuration can violate the constraint slightly. You also need to specify the initial relative angle for joint limits. This helps when saving and loading a game.

Note
The local anchor points are measured from the body's origin rather than the center of mass because:
  1. you might not know where the center of mass will be;
  2. if you add/remove shapes from a body and recompute the mass, the joints will be broken.
You can limit the relative rotation with a joint limit that specifies a lower and upper angle. You can use a motor to drive the relative rotation about the shared point. A maximum motor torque is provided so that infinite forces are not generated.
See also
https://en.wikipedia.org/wiki/Revolute_joint
Joint, World::CreateJoint
Examples
RevoluteJoint.cpp, and World.cpp.

Friends And Related Function Documentation

◆ InitVelocity()

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

◆ SolvePosition()

bool SolvePosition ( const RevoluteJointConf 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 ( RevoluteJointConf 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

◆ angularMotorImpulse

AngularMomentum playrho::d2::RevoluteJointConf::angularMotorImpulse = {}

Motor impulse.

Note
Modified by: InitVelocity, SolveVelocity.

◆ impulse

Vec3 playrho::d2::RevoluteJointConf::impulse = Vec3{}

Impulse.

Note
Modified by: InitVelocity, SolveVelocityConstraints.

◆ referenceAngle

Angle playrho::d2::RevoluteJointConf::referenceAngle = 0_deg

Reference angle.

This is the body-B angle minus body-A angle in the reference state (radians).

Examples
RevoluteJoint.cpp.

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