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

Prismatic joint definition. More...

#include <playrho/d2/PrismaticJointConf.hpp>

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

Public Types

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

Public Member Functions

constexpr PrismaticJointConf () noexcept=default
 Default constructor.
 
 PrismaticJointConf (BodyID bA, BodyID bB, const Length2 &laA=Length2{}, const Length2 &laB=Length2{}, const UnitVec &axisA=UnitVec::GetRight(), Angle angle=0_deg) noexcept
 Initializing constructor. More...
 
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 & UseLowerLength (Length v) noexcept
 Uses the given lower translation value.
 
constexpr auto & UseMaxMotorForce (Force v) noexcept
 Uses the given max motor force value.
 
constexpr auto & UseMotorSpeed (AngularVelocity v) noexcept
 Uses the given motor speed value.
 
constexpr auto & UseUpperLength (Length v) noexcept
 Uses the given upper translation value.
 
- Public Member Functions inherited from playrho::d2::JointBuilder< PrismaticJointConf >
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

Length a1 = 0_m
 Location A-1.
 
Length a2 = 0_m
 Location A-2.
 
UnitVec axis = UnitVec::GetZero()
 Axis.
 
bool enableLimit = false
 Enable/disable the joint limit.
 
bool enableMotor = false
 Enable/disable the joint motor.
 
Vec3 impulse = Vec3{}
 Impulse.
 
Mat33 K = {}
 K matrix.
 
LimitState limitState = LimitState::e_inactiveLimit
 Limit state.
 
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 unit axis in body A.
 
UnitVec localYAxisA = GetRevPerpendicular(UnitVec::GetRight())
 The local Y translation unit axis in body A.
 
Length lowerTranslation = 0_m
 The lower translation limit.
 
Force maxMotorForce = 0_N
 The maximum motor force.
 
Momentum motorImpulse = 0_Ns
 Motor impulse.
 
Mass motorMass = 0_kg
 Motor mass.
 
AngularVelocity motorSpeed = 0_rpm
 The desired angular motor speed.
 
UnitVec perp = UnitVec::GetZero()
 Perpendicular.
 
Angle referenceAngle = 0_deg
 The constrained angle between the bodies: body B's angle minus body A's angle.
 
Length s1 = 0_m
 Location S-1.
 
Length s2 = 0_m
 Location S-2.
 
Length upperTranslation = 0_m
 The upper translation 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.)

AngularMomentum GetAngularReaction (const PrismaticJointConf &conf)
 Gets the current angular reaction of the given configuration.
 
constexpr auto GetLinearLowerLimit (const PrismaticJointConf &conf) noexcept
 Free function for getting the linear lower limit value of the given configuration.
 
Momentum2 GetLinearReaction (const PrismaticJointConf &conf)
 Gets the current linear reaction of the given configuration.
 
constexpr auto GetLinearUpperLimit (const PrismaticJointConf &conf) noexcept
 Free function for getting the linear upper limit value of the given configuration.
 
void InitVelocity (PrismaticJointConf &object, const Span< BodyConstraint > &bodies, const StepConf &step, const ConstraintSolverConf &conf)
 Initializes velocity constraint data based on the given solver data. More...
 
constexpr void SetLinearLimits (PrismaticJointConf &conf, Length lower, Length upper) noexcept
 Free function for setting the linear limits of the given configuration.
 
constexpr void SetMaxMotorForce (PrismaticJointConf &object, Force value)
 Free function for setting the maximum motor torque value of the given configuration.
 
constexpr auto ShiftOrigin (PrismaticJointConf &, const Length2 &) noexcept
 Shifts the origin notion of the given configuration.
 
bool SolvePosition (const PrismaticJointConf &object, const Span< BodyConstraint > &bodies, const ConstraintSolverConf &conf)
 Solves the position constraint. More...
 
bool SolveVelocity (PrismaticJointConf &object, const Span< BodyConstraint > &bodies, const StepConf &step)
 Solves velocity constraint. More...
 

Detailed Description

Prismatic joint definition.

This joint provides one degree of freedom: translation along an axis fixed in body-A. Relative rotation is prevented. 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
You can use a joint limit to restrict the range of motion and a joint motor to drive the motion or to model joint friction.
See also
https://en.wikipedia.org/wiki/Prismatic_joint
Joint, World::CreateJoint

Constructor & Destructor Documentation

◆ PrismaticJointConf()

playrho::d2::PrismaticJointConf::PrismaticJointConf ( BodyID  bA,
BodyID  bB,
const Length2 laA = Length2{},
const Length2 laB = Length2{},
const UnitVec axisA = UnitVec::GetRight(),
Angle  angle = 0_deg 
)
noexcept

Initializing constructor.

Initializes the bodies, anchors, axis, and reference angle using the world anchor and unit world axis.

Friends And Related Function Documentation

◆ InitVelocity()

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

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