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

Revolute joint definition. More...

#include <playrho/d2/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 reference = value_type &
 Reference type.
 
using value_type = RevoluteJointConf
 Value type.
 

Public Member Functions

constexpr RevoluteJointConf () noexcept=default
 Default constructor.
 
 RevoluteJointConf (BodyID bA, BodyID bB, const Length2 &laA=Length2{}, const 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 & UseEnableMotor (bool v) noexcept
 Uses the given enable motor state value.
 
constexpr auto & UseLowerAngle (Angle v) noexcept
 Uses the given lower angle value.
 
constexpr auto & UseMaxMotorTorque (Torque v) noexcept
 Uses the given max motor torque value.
 
constexpr auto & UseMotorSpeed (AngularVelocity v) noexcept
 Uses the given motor speed value.
 
constexpr auto & UseUpperAngle (Angle v) noexcept
 Uses the given upper angle 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

RotInertia angularMass = {}
 Effective mass for motor/limit angular constraint.
 
AngularMomentum angularMotorImpulse = {}
 Motor impulse. More...
 
bool enableLimit = false
 Flag to enable joint limits.
 
bool enableMotor = false
 Flag to enable the joint motor.
 
Vec3 impulse = Vec3{}
 Impulse. More...
 
LimitState limitState = LimitState::e_inactiveLimit
 Limit state.
 
Length2 localAnchorA = Length2{}
 Local anchor point relative to body A's origin.
 
Length2 localAnchorB = Length2{}
 Local anchor point relative to body B's origin.
 
Angle lowerAngle = 0_deg
 Lower angle for the joint limit.
 
Mat33 mass = {}
 Effective mass for point-to-point constraint.
 
Torque maxMotorTorque = 0_Nm
 Maximum motor torque used to achieve the desired motor speed.
 
AngularVelocity motorSpeed = 0_rpm
 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.
 
Angle referenceAngle = 0_deg
 Reference angle. More...
 
Angle upperAngle = 0_deg
 Upper angle for the joint limit.
 
- 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 Angle GetAngularLowerLimit (const RevoluteJointConf &conf) noexcept
 Free function for getting the angular lower limit value of the given configuration.
 
constexpr AngularMomentum GetAngularReaction (const RevoluteJointConf &conf) noexcept
 Gets the current angular reaction 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.
 
void InitVelocity (RevoluteJointConf &object, const Span< BodyConstraint > &bodies, const StepConf &step, const ConstraintSolverConf &conf)
 Initializes velocity constraint data based on the given solver data. 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.
 
constexpr auto ShiftOrigin (RevoluteJointConf &, const Length2 &) noexcept
 Shifts the origin notion of the given configuration.
 
bool SolvePosition (const RevoluteJointConf &object, const Span< BodyConstraint > &bodies, const ConstraintSolverConf &conf)
 Solves the position constraint. More...
 
bool SolveVelocity (RevoluteJointConf &object, const Span< BodyConstraint > &bodies, const StepConf &step)
 Solves velocity constraint. More...
 

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

Friends And Related Function Documentation

◆ InitVelocity()

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

◆ SolvePosition()

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

◆ 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).


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