Box2D 2.4.1
A 2D physics engine for games
b2GearJoint Class Reference

#include <b2_gear_joint.h>

Inheritance diagram for b2GearJoint:
b2Joint

Public Member Functions

b2Vec2 GetAnchorA () const override
 Get the anchor point on bodyA in world coordinates. More...
 
b2Vec2 GetAnchorB () const override
 Get the anchor point on bodyB in world coordinates. More...
 
b2Vec2 GetReactionForce (float inv_dt) const override
 Get the reaction force on bodyB at the joint anchor in Newtons. More...
 
float GetReactionTorque (float inv_dt) const override
 Get the reaction torque on bodyB in N*m. More...
 
b2JointGetJoint1 ()
 Get the first joint.
 
b2JointGetJoint2 ()
 Get the second joint.
 
void SetRatio (float ratio)
 Set/Get the gear ratio.
 
float GetRatio () const
 
void Dump () override
 Dump joint to dmLog. More...
 
- Public Member Functions inherited from b2Joint
b2JointType GetType () const
 Get the type of the concrete joint.
 
b2BodyGetBodyA ()
 Get the first body attached to this joint.
 
b2BodyGetBodyB ()
 Get the second body attached to this joint.
 
virtual b2Vec2 GetAnchorA () const =0
 Get the anchor point on bodyA in world coordinates. More...
 
virtual b2Vec2 GetAnchorB () const =0
 Get the anchor point on bodyB in world coordinates. More...
 
virtual b2Vec2 GetReactionForce (float inv_dt) const =0
 Get the reaction force on bodyB at the joint anchor in Newtons. More...
 
virtual float GetReactionTorque (float inv_dt) const =0
 Get the reaction torque on bodyB in N*m. More...
 
b2JointGetNext ()
 Get the next joint the world joint list.
 
const b2JointGetNext () const
 
b2JointUserDataGetUserData ()
 Get the user data pointer.
 
bool IsEnabled () const
 Short-cut function to determine if either body is enabled.
 
bool GetCollideConnected () const
 
virtual void Dump ()
 Dump this joint to the log file. More...
 
virtual void ShiftOrigin (const b2Vec2 &newOrigin)
 Shift the origin for any points stored in world coordinates. More...
 
virtual void Draw (b2Draw *draw) const
 Debug draw this joint. More...
 

Protected Member Functions

 b2GearJoint (const b2GearJointDef *data)
 
void InitVelocityConstraints (const b2SolverData &data) override
 
void SolveVelocityConstraints (const b2SolverData &data) override
 
bool SolvePositionConstraints (const b2SolverData &data) override
 
- Protected Member Functions inherited from b2Joint
 b2Joint (const b2JointDef *def)
 
virtual void InitVelocityConstraints (const b2SolverData &data)=0
 
virtual void SolveVelocityConstraints (const b2SolverData &data)=0
 
virtual bool SolvePositionConstraints (const b2SolverData &data)=0
 

Protected Attributes

b2Jointm_joint1
 
b2Jointm_joint2
 
b2JointType m_typeA
 
b2JointType m_typeB
 
b2Bodym_bodyC
 
b2Bodym_bodyD
 
b2Vec2 m_localAnchorA
 
b2Vec2 m_localAnchorB
 
b2Vec2 m_localAnchorC
 
b2Vec2 m_localAnchorD
 
b2Vec2 m_localAxisC
 
b2Vec2 m_localAxisD
 
float m_referenceAngleA
 
float m_referenceAngleB
 
float m_constant
 
float m_ratio
 
float m_impulse
 
int32 m_indexA
 
int32 m_indexB
 
int32 m_indexC
 
int32 m_indexD
 
b2Vec2 m_lcA
 
b2Vec2 m_lcB
 
b2Vec2 m_lcC
 
b2Vec2 m_lcD
 
float m_mA
 
float m_mB
 
float m_mC
 
float m_mD
 
float m_iA
 
float m_iB
 
float m_iC
 
float m_iD
 
b2Vec2 m_JvAC
 
b2Vec2 m_JvBD
 
float m_JwA
 
float m_JwB
 
float m_JwC
 
float m_JwD
 
float m_mass
 
- Protected Attributes inherited from b2Joint
b2JointType m_type
 
b2Jointm_prev
 
b2Jointm_next
 
b2JointEdge m_edgeA
 
b2JointEdge m_edgeB
 
b2Bodym_bodyA
 
b2Bodym_bodyB
 
int32 m_index
 
bool m_islandFlag
 
bool m_collideConnected
 
b2JointUserData m_userData
 

Friends

class b2Joint
 

Additional Inherited Members

- Static Protected Member Functions inherited from b2Joint
static b2JointCreate (const b2JointDef *def, b2BlockAllocator *allocator)
 
static void Destroy (b2Joint *joint, b2BlockAllocator *allocator)
 

Detailed Description

A gear joint is used to connect two joints together. Either joint can be a revolute or prismatic joint. You specify a gear ratio to bind the motions together: coordinate1 + ratio * coordinate2 = constant The ratio can be negative or positive. If one joint is a revolute joint and the other joint is a prismatic joint, then the ratio will have units of length or units of 1/length.

Warning
You have to manually destroy the gear joint if joint1 or joint2 is destroyed.

Member Function Documentation

◆ Dump()

void b2GearJoint::Dump ( )
overridevirtual

Dump joint to dmLog.

Reimplemented from b2Joint.

◆ GetAnchorA()

b2Vec2 b2GearJoint::GetAnchorA ( ) const
overridevirtual

Get the anchor point on bodyA in world coordinates.

Implements b2Joint.

◆ GetAnchorB()

b2Vec2 b2GearJoint::GetAnchorB ( ) const
overridevirtual

Get the anchor point on bodyB in world coordinates.

Implements b2Joint.

◆ GetReactionForce()

b2Vec2 b2GearJoint::GetReactionForce ( float  inv_dt) const
overridevirtual

Get the reaction force on bodyB at the joint anchor in Newtons.

Implements b2Joint.

◆ GetReactionTorque()

float b2GearJoint::GetReactionTorque ( float  inv_dt) const
overridevirtual

Get the reaction torque on bodyB in N*m.

Implements b2Joint.

◆ InitVelocityConstraints()

void b2GearJoint::InitVelocityConstraints ( const b2SolverData data)
overrideprotectedvirtual

Implements b2Joint.

◆ SolvePositionConstraints()

bool b2GearJoint::SolvePositionConstraints ( const b2SolverData data)
overrideprotectedvirtual

Implements b2Joint.

◆ SolveVelocityConstraints()

void b2GearJoint::SolveVelocityConstraints ( const b2SolverData data)
overrideprotectedvirtual

Implements b2Joint.


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