Box2D  3.0.0
A Real-Time-Oriented 2-D Physics Engine
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
box2d::VelocityConstraint Class Reference

Contact velocity constraint. More...

#include <VelocityConstraint.hpp>

Classes

struct  Conf
 
struct  Point
 Velocity constraint point. More...
 

Public Types

using size_type = std::remove_const< decltype(MaxManifoldPoints)>::type
 
using index_type = size_t
 

Public Member Functions

 VelocityConstraint ()=default
 Default constructor. More...
 
 VelocityConstraint (const VelocityConstraint &copy)=default
 
VelocityConstraintoperator= (const VelocityConstraint &copy)=default
 
 VelocityConstraint (index_type contactIndex, RealNum friction, RealNum restitution, LinearVelocity tangentSpeed, const Manifold &manifold, BodyConstraint &bA, Length rA, BodyConstraint &bB, Length rB, Conf conf)
 
UnitVec2 GetNormal () const noexcept
 Gets the normal of the contact in world coordinates. More...
 
UnitVec2 GetTangent () const noexcept
 
InvMass GetInvMass () const noexcept
 
size_type GetPointCount () const noexcept
 Gets the count of points added to this object. More...
 
Mat22 GetK () const noexcept
 Gets the "K" value. More...
 
Mat22 GetNormalMass () const noexcept
 Gets the normal mass. More...
 
index_type GetContactIndex () const noexcept
 Gets the contact index. More...
 
RealNum GetFriction () const noexcept
 Gets the combined friction of the associated contact. More...
 
RealNum GetRestitution () const noexcept
 Gets the combined restitution of the associated contact. More...
 
LinearVelocity GetTangentSpeed () const noexcept
 Gets the tangent speed of the associated contact. More...
 
Momentum GetNormalImpulseAtPoint (size_type index) const noexcept
 Gets the normal impulse at the given point. More...
 
Momentum GetTangentImpulseAtPoint (size_type index) const noexcept
 Gets the tangent impulse at the given point. More...
 
LinearVelocity GetVelocityBiasAtPoint (size_type index) const noexcept
 Gets the velocity bias at the given point. More...
 
Mass GetNormalMassAtPoint (size_type index) const noexcept
 Gets the normal mass at the given point. More...
 
Mass GetTangentMassAtPoint (size_type index) const noexcept
 Gets the tangent mass at the given point. More...
 
Length2D GetPointRelPosA (size_type index) const noexcept
 Gets the point relative position of A. More...
 
Length2D GetPointRelPosB (size_type index) const noexcept
 Gets the point relative position of B. More...
 
void SetNormalImpulseAtPoint (size_type index, Momentum value)
 
void SetTangentImpulseAtPoint (size_type index, Momentum value)
 
const PointGetPointAt (size_type index) const
 Accesses the point identified by the given index. More...
 

Public Attributes

BodyConstraintbodyA
 Body A contact velocity constraint data. More...
 
BodyConstraintbodyB
 Body B contact velocity constraint data. More...
 

Detailed Description

Contact velocity constraint.

Note
A valid contact velocity constraint must have a point count of either 1 or 2.
This data structure is 168-bytes large (on at least one 64-bit platform).
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 biasses cannot be changed independent of: the normal, and the point relative positions.

Member Typedef Documentation

◆ index_type

◆ size_type

using box2d::VelocityConstraint::size_type = std::remove_const<decltype(MaxManifoldPoints)>::type

Constructor & Destructor Documentation

◆ VelocityConstraint() [1/3]

box2d::VelocityConstraint::VelocityConstraint ( )
default

Default constructor.

Initializes object with: a zero point count, an invalid K, an invalid normal mass, an invalid normal, invalid friction, invalid restitution, an invalid tangent speed.

◆ VelocityConstraint() [2/3]

box2d::VelocityConstraint::VelocityConstraint ( const VelocityConstraint copy)
default

◆ VelocityConstraint() [3/3]

VelocityConstraint::VelocityConstraint ( index_type  contactIndex,
RealNum  friction,
RealNum  restitution,
LinearVelocity  tangentSpeed,
const Manifold manifold,
BodyConstraint bA,
Length  rA,
BodyConstraint bB,
Length  rB,
Conf  conf 
)

Member Function Documentation

◆ GetContactIndex()

index_type box2d::VelocityConstraint::GetContactIndex ( ) const
inlinenoexcept

Gets the contact index.

Note
This value can only be set via the initializing constructor.
Returns
Index of the associated contact (the index of the contact that this constraint is for).

◆ GetFriction()

RealNum box2d::VelocityConstraint::GetFriction ( ) const
inlinenoexcept

Gets the combined friction of the associated contact.

◆ GetInvMass()

InvMass box2d::VelocityConstraint::GetInvMass ( ) const
inlinenoexcept

◆ GetK()

Mat22 box2d::VelocityConstraint::GetK ( ) const
inlinenoexcept

Gets the "K" value.

Note
This value is only valid if previously set.
Call the SetK method to set this value.
Returns
"K" value previously set or an invalid value.
"K" value or an invalid Mat22 if no other value has been set.
See also
SetK.

◆ GetNormal()

UnitVec2 box2d::VelocityConstraint::GetNormal ( ) const
inlinenoexcept

Gets the normal of the contact in world coordinates.

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

◆ GetNormalImpulseAtPoint()

Momentum box2d::VelocityConstraint::GetNormalImpulseAtPoint ( VelocityConstraint::size_type  index) const
inlinenoexcept

Gets the normal impulse at the given point.

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

◆ GetNormalMass()

Mat22 box2d::VelocityConstraint::GetNormalMass ( ) const
inlinenoexcept

Gets the normal mass.

Gets the "normal mass" value.

Note
This value is only valid if previously set.
Returns
normal mass previously set or an invalid value.
"normal mass" value or the invalid Mat22 if no other value has been set.
See also
SetK.

◆ GetNormalMassAtPoint()

Mass box2d::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 method sets this value.

◆ GetPointAt()

const Point& box2d::VelocityConstraint::GetPointAt ( size_type  index) const
inline

Accesses the point identified by the given index.

Note
Behavior is undefined if given index is not less than MaxManifoldPoints.
Parameters
indexIndex of the point to return. This should be a value less than returned by GetPointCount().
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 box2d::VelocityConstraint::GetPointCount ( ) const
inlinenoexcept

Gets the count of points added to this object.

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

◆ GetPointRelPosA()

Length2D box2d::VelocityConstraint::GetPointRelPosA ( VelocityConstraint::size_type  index) const
inlinenoexcept

Gets the point relative position of A.

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

◆ GetPointRelPosB()

Length2D box2d::VelocityConstraint::GetPointRelPosB ( VelocityConstraint::size_type  index) const
inlinenoexcept

Gets the point relative position of B.

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

◆ GetRestitution()

RealNum box2d::VelocityConstraint::GetRestitution ( ) const
inlinenoexcept

Gets the combined restitution of the associated contact.

◆ GetTangent()

UnitVec2 box2d::VelocityConstraint::GetTangent ( ) const
inlinenoexcept

◆ GetTangentImpulseAtPoint()

Momentum box2d::VelocityConstraint::GetTangentImpulseAtPoint ( VelocityConstraint::size_type  index) const
inlinenoexcept

Gets the tangent impulse at the given point.

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

◆ GetTangentMassAtPoint()

Mass box2d::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 method sets this value.

◆ GetTangentSpeed()

LinearVelocity box2d::VelocityConstraint::GetTangentSpeed ( ) const
inlinenoexcept

Gets the tangent speed of the associated contact.

◆ GetVelocityBiasAtPoint()

LinearVelocity box2d::VelocityConstraint::GetVelocityBiasAtPoint ( size_type  index) const
inlinenoexcept

Gets the velocity bias at the given point.

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

◆ operator=()

VelocityConstraint& box2d::VelocityConstraint::operator= ( const VelocityConstraint copy)
default

◆ SetNormalImpulseAtPoint()

void box2d::VelocityConstraint::SetNormalImpulseAtPoint ( VelocityConstraint::size_type  index,
Momentum  value 
)
inline

◆ SetTangentImpulseAtPoint()

void box2d::VelocityConstraint::SetTangentImpulseAtPoint ( VelocityConstraint::size_type  index,
Momentum  value 
)
inline

Member Data Documentation

◆ bodyA

BodyConstraint& box2d::VelocityConstraint::bodyA

Body A contact velocity constraint data.

◆ bodyB

BodyConstraint& box2d::VelocityConstraint::bodyB

Body B contact velocity constraint data.


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