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

Target joint definition. More...

#include <playrho/d2/TargetJointConf.hpp>

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

Public Types

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

Public Member Functions

constexpr TargetJointConf () noexcept=default
 Default constructor.
 
constexpr TargetJointConf (BodyID b) noexcept
 Initializing constructor.
 
constexpr auto & UseAnchor (const Length2 &v) noexcept
 Use value for the "anchor" (in coordinates local to "body B"). More...
 
constexpr auto & UseDampingRatio (NonNegative< Real > v) noexcept
 Use value for damping ratio.
 
constexpr auto & UseFrequency (NonNegative< Frequency > v) noexcept
 Use value for frequency.
 
constexpr auto & UseMaxForce (NonNegative< Force > v) noexcept
 Use value for max force.
 
constexpr auto & UseTarget (const Length2 &v) noexcept
 Use value for target.
 
- Public Member Functions inherited from playrho::d2::JointBuilder< TargetJointConf >
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

LinearVelocity2 C = {}
 Velocity constant.
 
NonNegative< RealdampingRatio = DefaultDampingRatio
 The damping ratio. 0 = no damping, 1 = critical damping.
 
NonNegative< Frequencyfrequency = DefaultFrequency
 
InvMass gamma = InvMass{}
 Gamma.
 
Momentum2 impulse = Momentum2{}
 Impulse.
 
Length2 localAnchorB = Length2{}
 Anchor point.
 
Mass22 mass = {}
 2-by-2 mass matrix in kilograms.
 
NonNegative< ForcemaxForce = DefaultMaxForce
 
Length2 rB = {}
 Relative B.
 
Length2 target = Length2{}
 
- 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...
 

Static Public Attributes

static constexpr auto DefaultDampingRatio = NonNegativeFF<Real>(static_cast<Real>(0.7f))
 Default damping ratio.
 
static constexpr auto DefaultFrequency = NonNegativeFF<Frequency>(5_Hz)
 Default frequency.
 
static constexpr auto DefaultMaxForce = NonNegativeFF<Force>(0_N)
 Default max force.
 

Related Functions

(Note that these are not member functions.)

constexpr AngularMomentum GetAngularReaction (const TargetJointConf &)
 Gets the current angular reaction of the given configuration.
 
Mass22 GetEffectiveMassMatrix (const TargetJointConf &object, const BodyConstraint &body) noexcept
 Gets the effective mass matrix for the given configuration and body information.
 
constexpr Momentum2 GetLinearReaction (const TargetJointConf &object)
 Gets the current linear reaction of the given configuration.
 
constexpr auto GetLocalAnchorA (const TargetJointConf &) noexcept
 Gets the local anchar A for the given configuration.
 
constexpr auto GetMaxForce (const TargetJointConf &object) noexcept
 Free function for getting the maximum force value of the given configuration.
 
constexpr auto GetTarget (const TargetJointConf &object) noexcept
 Free function for getting the target value of the given configuration.
 
void InitVelocity (TargetJointConf &object, const Span< BodyConstraint > &bodies, const StepConf &step, const ConstraintSolverConf &conf)
 Initializes velocity constraint data based on the given solver data. More...
 
constexpr void SetDampingRatio (TargetJointConf &object, Real value) noexcept
 Free function for setting the damping ratio value of the given configuration.
 
constexpr void SetFrequency (TargetJointConf &object, NonNegative< Frequency > value) noexcept
 Free function for setting the frequency value of the given configuration.
 
constexpr auto SetMaxForce (TargetJointConf &object, NonNegative< Force > value) noexcept
 Free function for setting the maximum force value of the given configuration.
 
constexpr void SetTarget (TargetJointConf &object, const Length2 &value) noexcept
 Free function for setting the target value of the given configuration.
 
constexpr bool ShiftOrigin (TargetJointConf &object, const Length2 &newOrigin)
 Shifts the origin notion of the given configuration.
 
bool SolvePosition (const TargetJointConf &object, const Span< BodyConstraint > &bodies, const ConstraintSolverConf &conf)
 Solves the position constraint. More...
 
bool SolveVelocity (TargetJointConf &object, const Span< BodyConstraint > &bodies, const StepConf &step)
 Solves velocity constraint. More...
 

Detailed Description

Target joint definition.

A target joint is used to make a point on a body track a specified world point. This a soft constraint with a maximum force. This allows the constraint to stretch and without applying huge forces.

See also
Joint, World::CreateJoint

Member Function Documentation

◆ UseAnchor()

constexpr auto& playrho::d2::TargetJointConf::UseAnchor ( const Length2 v)
inlineconstexprnoexcept

Use value for the "anchor" (in coordinates local to "body B").

Note
Typically this would be the value of: bodyB != InvalidBodyID ? GetLocalPoint(GetBody(world, bodyB), target) : Length2().

Friends And Related Function Documentation

◆ InitVelocity()

void InitVelocity ( TargetJointConf 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. bodyB must index a body 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 bodyB value is not InvalidBodyID and does not index within range of the given bodies container.
See also
SolveVelocity.

◆ SolvePosition()

bool SolvePosition ( const TargetJointConf object,
const Span< BodyConstraint > &  bodies,
const ConstraintSolverConf conf 
)
related

Solves the position constraint.

Note
This is a no-op and always returns true.
Returns
true.

◆ SolveVelocity()

bool SolveVelocity ( TargetJointConf object,
const Span< BodyConstraint > &  bodies,
const StepConf step 
)
related

Solves velocity constraint.

Precondition
InitVelocity has been called.
Parameters
objectConfiguration object. bodyB must index a body 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 bodyB value is not InvalidBodyID and does not index within range of the given bodies container.
See also
InitVelocity.
Returns
true if velocity is "solved", false otherwise.

Member Data Documentation

◆ frequency

NonNegative<Frequency> playrho::d2::TargetJointConf::frequency = DefaultFrequency

Frequency.

The has to do with the response speed.

Note
This value may not be negative.

Referenced by UseFrequency().

◆ maxForce

NonNegative<Force> playrho::d2::TargetJointConf::maxForce = DefaultMaxForce

Max force.

The maximum constraint force that can be exerted to move the candidate body. Usually you will express as some multiple of the weight (multiplier * mass * gravity).

Note
This may not be negative.

Referenced by UseMaxForce().

◆ target

Length2 playrho::d2::TargetJointConf::target = Length2{}

The initial world target point. This is assumed to coincide with the body anchor initially.

Referenced by UseTarget().


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