A joint-like constraint on one or more bodies. More...
#include <Joint.hpp>
Classes | |
struct | Concept |
Internal configuration concept. More... | |
struct | Model |
Internal model configuration concept. More... | |
Public Types | |
using | BodyConstraintsMap = std::vector< BodyConstraint > |
Type alias for body constraints mapping. | |
Public Member Functions | |
Joint () noexcept=default | |
Default constructor. More... | |
Joint (const Joint &other) | |
Copy constructor. More... | |
Joint (Joint &&other) noexcept | |
Move constructor. More... | |
template<typename T , typename Tp = DecayedTypeIfNotSelf<T>, typename = std::enable_if_t<std::is_copy_constructible<Tp>::value>> | |
Joint (T &&arg) | |
Initializing constructor. More... | |
Joint & | operator= (const Joint &other) |
Copy assignment. More... | |
Joint & | operator= (Joint &&other) noexcept |
Move assignment. More... | |
template<typename T , typename Tp = DecayedTypeIfNotSelf<T>, typename = std::enable_if_t<std::is_copy_constructible<Tp>::value>> | |
Joint & | operator= (T &&other) noexcept |
Move assignment support for any valid underlying configuration. More... | |
void | swap (Joint &other) noexcept |
Swap function. | |
bool | has_value () const noexcept |
Checks whether this instance contains a value. | |
Private Types | |
template<typename Type , typename DecayedType = std::decay_t<Type>> | |
using | DecayedTypeIfNotSelf = std::enable_if_t<!std::is_same_v< DecayedType, Joint >, DecayedType > |
Decayed type if not same as this class. More... | |
Private Attributes | |
std::unique_ptr< Concept > | m_self |
Self pointer. | |
Friends | |
TypeID | GetType (const Joint &object) noexcept |
Gets the identifier of the type of data this can be casted to. | |
template<typename T > | |
std::add_pointer_t< std::add_const_t< T > > | TypeCast (const Joint *value) noexcept |
Converts the given joint into its current configuration value. More... | |
template<typename T > | |
std::add_pointer_t< T > | TypeCast (Joint *value) noexcept |
Converts the given joint into its current configuration value. More... | |
bool | operator== (const Joint &lhs, const Joint &rhs) noexcept |
Equality operator for joint comparisons. | |
bool | operator!= (const Joint &lhs, const Joint &rhs) noexcept |
Inequality operator for joint comparisons. | |
BodyID | GetBodyA (const Joint &object) noexcept |
Gets the first body attached to this joint. | |
BodyID | GetBodyB (const Joint &object) noexcept |
Gets the second body attached to this joint. | |
bool | GetCollideConnected (const Joint &object) noexcept |
Gets collide connected. More... | |
bool | ShiftOrigin (Joint &object, Length2 value) noexcept |
Shifts the origin for any points stored in world coordinates. More... | |
void | InitVelocity (Joint &object, std::vector< BodyConstraint > &bodies, const playrho::StepConf &step, const ConstraintSolverConf &conf) |
Initializes velocity constraint data based on the given solver data. More... | |
bool | SolveVelocity (Joint &object, std::vector< BodyConstraint > &bodies, const playrho::StepConf &step) |
Solves velocity constraint. More... | |
bool | SolvePosition (const Joint &object, std::vector< BodyConstraint > &bodies, const ConstraintSolverConf &conf) |
Solves the position constraint. More... | |
Related Functions | |
(Note that these are not member functions.) | |
DistanceJointConf | GetDistanceJointConf (const Joint &joint) noexcept |
Gets the definition data for the given joint. | |
FrictionJointConf | GetFrictionJointConf (const Joint &joint) noexcept |
Gets the definition data for the given joint. | |
GearJointConf | GetGearJointConf (const Joint &joint) noexcept |
Gets the definition data for the given joint. | |
template<typename T > | |
T | TypeCast (const Joint &value) |
Converts the given joint into its current configuration value. More... | |
template<typename T > | |
T | TypeCast (Joint &value) |
Converts the given joint into its current configuration value. More... | |
template<typename T > | |
T | TypeCast (Joint &&value) |
Converts the given joint into its current configuration value. More... | |
Length2 | GetLocalAnchorA (const Joint &object) |
Get the anchor point on body-A in local coordinates. | |
Length2 | GetLocalAnchorB (const Joint &object) |
Get the anchor point on body-B in local coordinates. | |
Momentum2 | GetLinearReaction (const Joint &object) |
Get the linear reaction on body-B at the joint anchor. | |
AngularMomentum | GetAngularReaction (const Joint &object) |
Get the angular reaction on body-B. | |
Angle | GetReferenceAngle (const Joint &object) |
Gets the reference angle of the joint if it has one. More... | |
UnitVec | GetLocalXAxisA (const Joint &object) |
Gets the given joint's local X axis A if its type supports that. More... | |
UnitVec | GetLocalYAxisA (const Joint &object) |
Gets the given joint's local Y axis A if its type supports that. More... | |
AngularVelocity | GetMotorSpeed (const Joint &object) |
Gets the given joint's motor speed if its type supports that. More... | |
void | SetMotorSpeed (Joint &object, AngularVelocity value) |
Sets the given joint's motor speed if its type supports that. More... | |
Force | GetMaxForce (const Joint &object) |
Gets the given joint's max force if its type supports that. More... | |
Torque | GetMaxTorque (const Joint &object) |
Gets the given joint's max torque if its type supports that. More... | |
Force | GetMaxMotorForce (const Joint &object) |
Gets the given joint's max motor force if its type supports that. More... | |
void | SetMaxMotorForce (Joint &object, Force value) |
Sets the given joint's max motor force if its type supports that. More... | |
Torque | GetMaxMotorTorque (const Joint &object) |
Gets the given joint's max motor torque if its type supports that. More... | |
void | SetMaxMotorTorque (Joint &object, Torque value) |
Sets the given joint's max motor torque if its type supports that. More... | |
RotInertia | GetAngularMass (const Joint &object) |
Gets the given joint's angular mass. More... | |
Real | GetRatio (const Joint &object) |
Gets the given joint's ratio property if it has one. More... | |
Real | GetDampingRatio (const Joint &object) |
Gets the given joint's damping ratio property if it has one. More... | |
Frequency | GetFrequency (const Joint &object) |
Gets the frequency of the joint if it has this property. More... | |
void | SetFrequency (Joint &object, Frequency value) |
Sets the frequency of the joint if it has this property. More... | |
AngularMomentum | GetAngularMotorImpulse (const Joint &object) |
Gets the angular motor impulse of the joint if it has this property. More... | |
Length2 | GetTarget (const Joint &object) |
Gets the given joint's target property if it has one. More... | |
void | SetTarget (Joint &object, Length2 value) |
Sets the given joint's target property if it has one. More... | |
Length | GetLinearLowerLimit (const Joint &object) |
Gets the lower linear joint limit. More... | |
Length | GetLinearUpperLimit (const Joint &object) |
Gets the upper linear joint limit. More... | |
void | SetLinearLimits (Joint &object, Length lower, Length upper) |
Sets the joint limits. More... | |
Angle | GetAngularLowerLimit (const Joint &object) |
Gets the lower joint limit. More... | |
Angle | GetAngularUpperLimit (const Joint &object) |
Gets the upper joint limit. More... | |
void | SetAngularLimits (Joint &object, Angle lower, Angle upper) |
Sets the joint limits. More... | |
bool | IsLimitEnabled (const Joint &object) |
Gets the specified joint's limit property if it supports one. More... | |
void | EnableLimit (Joint &object, bool value) |
Enables the specified joint's limit property if it supports one. More... | |
bool | IsMotorEnabled (const Joint &object) |
Gets the specified joint's motor property value if it supports one. More... | |
void | EnableMotor (Joint &object, bool value) |
Enables the specified joint's motor property if it supports one. More... | |
Length2 | GetLinearOffset (const Joint &object) |
Gets the linear offset property of the specified joint if its type has one. More... | |
void | SetLinearOffset (Joint &object, Length2 value) |
Sets the linear offset property of the specified joint if its type has one. More... | |
Angle | GetAngularOffset (const Joint &object) |
Gets the angular offset property of the specified joint if its type has one. More... | |
void | SetAngularOffset (Joint &object, Angle value) |
Sets the angular offset property of the specified joint if its type has one. More... | |
LimitState | GetLimitState (const Joint &object) |
Length2 | GetGroundAnchorA (const Joint &object) |
Length2 | GetGroundAnchorB (const Joint &object) |
Momentum | GetLinearMotorImpulse (const Joint &object) |
Length | GetLength (const Joint &object) |
Gets the length property of the specified joint if its type has one. More... | |
Torque | GetMotorTorque (const Joint &joint, Frequency inv_dt) |
Gets the current motor torque for the given joint given the inverse time step. More... | |
MotorJointConf | GetMotorJointConf (const Joint &joint) noexcept |
Gets the definition data for the given joint. | |
PrismaticJointConf | GetPrismaticJointConf (const Joint &joint) |
Gets the definition data for the given joint. | |
PulleyJointConf | GetPulleyJointConf (const Joint &joint) |
Gets the definition data for the given joint. | |
RevoluteJointConf | GetRevoluteJointConf (const Joint &joint) |
Gets the definition data for the given joint. | |
RopeJointConf | GetRopeJointConf (const Joint &joint) noexcept |
Gets the definition data for the given joint. | |
TargetJointConf | GetTargetJointConf (const Joint &joint) |
Gets the definition data for the given joint. | |
WeldJointConf | GetWeldJointConf (const Joint &joint) |
Gets the definition data for the given joint. | |
WheelJointConf | GetWheelJointConf (const Joint &joint) |
Gets the definition data for the given joint. | |
A joint-like constraint on one or more bodies.
This is a concrete manifestation of the joint concept. Joints are constraints that are used to constrain one or more bodies in various fashions. Some joints also feature limits and motors.
T
has at least the following function definitions available for it:bool operator==(const T& lhs, const T& rhs) noexcept;
BodyID GetBodyA(const T& object) noexcept;
BodyID GetBodyB(const T& object) noexcept;
bool GetCollideConnected(const T& object) noexcept;
bool ShiftOrigin(T& object, Length2 value) noexcept;
void InitVelocity(T& object, std::vector<BodyConstraint>& bodies, const StepConf& step, const ConstraintSolverConf& conf);
bool SolveVelocity(T& object, std::vector<BodyConstraint>& bodies, const StepConf& step);
bool SolvePosition(const T& object, std::vector<BodyConstraint>& bodies, const ConstraintSolverConf& conf);
|
private |
Decayed type if not same as this class.
|
defaultnoexcept |
Default constructor.
Constructs a joint that contains no value.
has_value()
returns false. GetType(const Joint&)
returns GetTypeID<void>()
. Referenced by operator=().
|
inline |
Copy constructor.
This constructor copies all the details of other.
|
inlinenoexcept |
Move constructor.
This constructor moves all the details of other into *this
and leaves other in the default constructed state.
|
inlineexplicit |
Initializing constructor.
T
for its values to be valid candidates for this function. explicit
to prevent implicit conversions and to provide preferable error messages from the compiler with less to-do when a type doesn't support one or more of the required functions. For instance, if there exists no function GetBodyA(const T&)
for the type T
, then clang issues the error: No matching function for call to 'GetBodyA'. explicit
and nothing else is done, then GetBodyA(const Joint&)
becomes eligible to satisfy that requirement (because of implicit conversion from T
to Joint
). This results in an exhaustive loop which is decidely less desirable than a compile time error. explicit
and const
rvalue reference taking versions of the required functions are deleted with definitions like BodyID GetBodyA(const Joint&&) noexcept = delete
, then clang issues an error of: Call to deleted function 'GetBodyA'. The idea for these deleted functions came from the article Controlling overload resolution #1: Preventing implicit conversions. While this would be preferable to discovering the issue at runtime, that's not as preferable as the error clang generates when this constructor is marked explicit
since this message points to the deleted function as the problem rather than directly to there being "no
matching function". std::any
, dealing with overload resolution of the required functions is less appealing than marking this constuctor explicit
as explained above. has_value()
returns true. Copy assignment.
This operator copies all the details of other into *this
.
Move assignment.
This operator moves all the details of other into *this
and leaves other in the default constructed state.
|
inlinenoexcept |
Move assignment support for any valid underlying configuration.
T
for its values to be valid candidates for this function. has_value()
returns true.
|
related |
Enables the specified joint's limit property if it supports one.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Enables the specified joint's motor property if it supports one.
std::invalid_argument | If not supported for the given joint's type. |
Gets the lower joint limit.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the given joint's angular mass.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the angular motor impulse of the joint if it has this property.
std::invalid_argument | If not supported for the given joint's type. |
Referenced by playrho::d2::GetMotorTorque().
Gets the angular offset property of the specified joint if its type has one.
std::invalid_argument | If not supported for the given joint's type. |
Gets the upper joint limit.
std::invalid_argument | If not supported for the given joint's type. |
|
friend |
Gets collide connected.
Referenced by playrho::d2::Joint::Model< T >::GetCollideConnected_().
Gets the given joint's damping ratio property if it has one.
std::invalid_argument | If not supported for the given joint's type. |
Gets the frequency of the joint if it has this property.
std::invalid_argument | If not supported for the given joint's type. |
std::invalid_argument | If not supported for the given joint's type. |
std::invalid_argument | If not supported for the given joint's type. |
Gets the length property of the specified joint if its type has one.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
std::invalid_argument | If not supported for the given joint's type. |
Gets the lower linear joint limit.
std::invalid_argument | If not supported for the given joint's type. |
std::invalid_argument | If not supported for the given joint's type. |
Gets the linear offset property of the specified joint if its type has one.
std::invalid_argument | If not supported for the given joint's type. |
Gets the upper linear joint limit.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's local X axis A if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's local Y axis A if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's max force if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's max motor force if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's max motor torque if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's max torque if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the given joint's motor speed if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Gets the current motor torque for the given joint given the inverse time step.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's ratio property if it has one.
std::invalid_argument | If not supported for the given joint's type. |
Gets the reference angle of the joint if it has one.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's target property if it has one.
std::invalid_argument | If not supported for the given joint's type. |
|
friend |
Initializes velocity constraint data based on the given solver data.
SolveVelocity
. Referenced by playrho::d2::Joint::Model< T >::InitVelocity_().
|
related |
Gets the specified joint's limit property if it supports one.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the specified joint's motor property value if it supports one.
std::invalid_argument | If not supported for the given joint's type. |
Sets the joint limits.
std::invalid_argument | If not supported for the given joint's type. |
Sets the angular offset property of the specified joint if its type has one.
std::invalid_argument | If not supported for the given joint's type. |
Sets the frequency of the joint if it has this property.
std::invalid_argument | If not supported for the given joint's type. |
Sets the joint limits.
std::invalid_argument | If not supported for the given joint's type. |
Sets the linear offset property of the specified joint if its type has one.
std::invalid_argument | If not supported for the given joint's type. |
Sets the given joint's max motor force if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Sets the given joint's max motor torque if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Sets the given joint's motor speed if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Sets the given joint's target property if it has one.
std::invalid_argument | If not supported for the given joint's type. |
Shifts the origin for any points stored in world coordinates.
true
if shift done, false
otherwise. Referenced by playrho::d2::Joint::Model< T >::ShiftOrigin_().
|
friend |
Solves the position constraint.
true
if the position errors are within tolerance. Referenced by playrho::d2::Joint::Model< T >::SolvePosition_().
|
friend |
Solves velocity constraint.
InitVelocity
has been called. true
if velocity is "solved", false
otherwise. Referenced by playrho::d2::Joint::Model< T >::SolveVelocity_().
|
related |
Converts the given joint into its current configuration value.
std::any
class and its associated std::any_cast
function. The code for this is based off of the std::any
implementation from the LLVM Project. std::bad_cast | If the given template parameter type isn't the type of this joint's configuration value. |
|
friend |
Converts the given joint into its current configuration value.
std::any
class and its associated std::any_cast
function. The code for this is based off of the std::any
code from the LLVM Project.
|
related |
Converts the given joint into its current configuration value.
std::any
class and its associated std::any_cast
function. The code for this is based off of the std::any
implementation from the LLVM Project.
|
related |
Converts the given joint into its current configuration value.
std::any
class and its associated std::any_cast
function. The code for this is based off of the std::any
implementation from the LLVM Project.
|
friend |
Converts the given joint into its current configuration value.
std::any
class and its associated std::any_cast
function. The code for this is based off of the std::any
implementation from the LLVM Project.