PlayRho  2.0.0
An interactive physics engine & library.
playrho::d2::VelocityConstraint Class Reference

The per-contact velocity constraint data structure. More...

#include <playrho/d2/VelocityConstraint.hpp>

Classes

struct  Conf
 Configuration data for velocity constraints. More...
 
struct  Point
 Velocity constraint point. More...
 

Public Types

using size_type = std::remove_const_t< decltype(MaxManifoldPoints)>
 Size type.
 

Public Member Functions

 VelocityConstraint ()=default
 Default constructor. More...
 
 VelocityConstraint (const VelocityConstraint &copy)=default
 Copy constructor.
 
 VelocityConstraint (Real friction, Real restitution, LinearVelocity tangentSpeed, const WorldManifold &worldManifold, BodyID bA, BodyID bB, const Span< const BodyConstraint > &bodies, const Conf &conf=GetDefaultConf())
 Initializing constructor.
 
BodyID GetBodyA () const noexcept
 Gets identifier of body A.
 
BodyID GetBodyB () const noexcept
 Gets identifier of body B.
 
Real GetFriction () const noexcept
 Gets the combined friction of the associated contact.
 
InvMass22 GetK () const noexcept
 
UnitVec GetNormal () const noexcept
 
Momentum GetNormalImpulseAtPoint (size_type index) const noexcept
 
Mass22 GetNormalMass () const noexcept
 
Mass GetNormalMassAtPoint (size_type index) const noexcept
 
const PointGetPointAt (size_type index) const
 Accesses the point identified by the given index. More...
 
size_type GetPointCount () const noexcept
 
Length2 GetPointRelPosA (size_type index) const noexcept
 
Length2 GetPointRelPosB (size_type index) const noexcept
 
Real GetRestitution () const noexcept
 Gets the combined restitution of the associated contact.
 
UnitVec GetTangent () const noexcept
 Gets the tangent.
 
Momentum GetTangentImpulseAtPoint (size_type index) const noexcept
 
Mass GetTangentMassAtPoint (size_type index) const noexcept
 
LinearVelocity GetTangentSpeed () const noexcept
 Gets the tangent speed of the associated contact.
 
LinearVelocity GetVelocityBiasAtPoint (size_type index) const noexcept
 
VelocityConstraintoperator= (const VelocityConstraint &copy)=default
 Assignment operator.
 
void SetNormalImpulseAtPoint (size_type index, Momentum value)
 Sets the normal impulse at the given point.
 
void SetTangentImpulseAtPoint (size_type index, Momentum value)
 Sets the tangent impulse at the given point.
 

Static Public Member Functions

static constexpr Conf GetDefaultConf () noexcept
 Gets the default configuration for a VelocityConstraint.
 

Detailed Description

The per-contact velocity constraint data structure.

Note
A valid contact velocity constraint must have a point count of either 1 or 2.
Invariant
The "K" value cannot be changed independent of: the total inverse mass, the normal, and the point relative positions.
The normal mass cannot be changed independent of: the "K" value.
The velocity biases cannot be changed independent of: the normal, and the point relative positions.

Constructor & Destructor Documentation

◆ VelocityConstraint()

playrho::d2::VelocityConstraint::VelocityConstraint ( )
default

Default constructor.

Postcondition
GetNormal() and GetTangent() return a default constructed UnitVec .
GetPointCount(), GetFriction(), GetRestitution(), GetTangentSpeed(), GetK(), GetNormalMass() all return zero.

Member Function Documentation

◆ GetK()

InvMass22 playrho::d2::VelocityConstraint::GetK ( ) const
inlinenoexcept

Gets the "K" value.

Note
This value is only valid if previously set to a valid value.
Returns
"K" value previously set or the zero initialized value.

◆ GetNormal()

UnitVec playrho::d2::VelocityConstraint::GetNormal ( ) const
inlinenoexcept

Gets the normal of the contact in world coordinates.

Note
This value is set on construction.
Returns
The contact normal (in world coordinates) if previously set, an invalid value otherwise.

◆ GetNormalImpulseAtPoint()

Momentum playrho::d2::VelocityConstraint::GetNormalImpulseAtPoint ( VelocityConstraint::size_type  index) const
inlinenoexcept

Gets the normal impulse at the given point.

Note
Call the AddPoint or SetNormalImpulseAtPoint function to set this value.
Returns
Value previously set, or an invalid value.
See also
SetNormalImpulseAtPoint.

Referenced by playrho::d2::GetNormalImpulseAtPoint().

◆ GetNormalMass()

Mass22 playrho::d2::VelocityConstraint::GetNormalMass ( ) const
inlinenoexcept

Gets the normal mass.

Note
This value is only valid if previously set.
Returns
normal mass previously set or the zero initialized value.

◆ GetNormalMassAtPoint()

Mass playrho::d2::VelocityConstraint::GetNormalMassAtPoint ( VelocityConstraint::size_type  index) const
inlinenoexcept

Gets the normal mass at the given point.

Note
This value depends on the values of: the sum of the inverse-masses of the two bodies, the bodies' inverse-rotational-inertia, the point-relative A and B positions, and the normal.
The AddPoint function sets this value.

Referenced by playrho::d2::GetNormalMassAtPoint().

◆ GetPointAt()

const Point& playrho::d2::VelocityConstraint::GetPointAt ( size_type  index) const
inline

Accesses the point identified by the given index.

Parameters
indexIndex of the point to return. This should be a value less than returned by GetPointCount.
Precondition
index is less than MaxManifoldPoints.
Returns
velocity constraint point for the given index. This point's data will be invalid unless previously added and set.
See also
GetPointCount.

◆ GetPointCount()

size_type playrho::d2::VelocityConstraint::GetPointCount ( ) const
inlinenoexcept

Gets the count of points added to this object.

Returns
Value between 0 and MaxManifoldPoints.
See also
MaxManifoldPoints.
AddPoint.

Referenced by playrho::d2::GetContactImpulses().

◆ GetPointRelPosA()

Length2 playrho::d2::VelocityConstraint::GetPointRelPosA ( VelocityConstraint::size_type  index) const
inlinenoexcept

Gets the point relative position of A.

Note
The AddPoint function sets this value.
Returns
Previously set value or an invalid value.

Referenced by playrho::d2::GetPointRelPosA().

◆ GetPointRelPosB()

Length2 playrho::d2::VelocityConstraint::GetPointRelPosB ( VelocityConstraint::size_type  index) const
inlinenoexcept

Gets the point relative position of B.

Note
The AddPoint function sets this value.
Returns
Previously set value or an invalid value.

Referenced by playrho::d2::GetPointRelPosB().

◆ GetTangentImpulseAtPoint()

Momentum playrho::d2::VelocityConstraint::GetTangentImpulseAtPoint ( VelocityConstraint::size_type  index) const
inlinenoexcept

Gets the tangent impulse at the given point.

Note
Call the AddPoint or SetTangentImpulseAtPoint function to set this value.
Returns
Value previously set, or an invalid value.
See also
SetTangentImpulseAtPoint.

Referenced by playrho::d2::GetTangentImpulseAtPoint().

◆ GetTangentMassAtPoint()

Mass playrho::d2::VelocityConstraint::GetTangentMassAtPoint ( VelocityConstraint::size_type  index) const
inlinenoexcept

Gets the tangent mass at the given point.

Note
This value depends on the values of: the sum of the inverse-masses of the two bodies, the bodies' inverse-rotational-inertia, the point-relative A and B positions, and the tangent.
The AddPoint function sets this value.

Referenced by playrho::d2::GetTangentMassAtPoint().

◆ GetVelocityBiasAtPoint()

LinearVelocity playrho::d2::VelocityConstraint::GetVelocityBiasAtPoint ( size_type  index) const
inlinenoexcept

Gets the velocity bias at the given point.

Note
The AddPoint function sets this value.
Returns
Previously set value or an invalid value.

Referenced by playrho::d2::GetVelocityBiasAtPoint().


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