Box2D
2.3.0
A 2D Physics Engine for Games
Box2D
Dynamics
Joints
b2GearJoint.h
1
/*
2
* Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
3
*
4
* This software is provided 'as-is', without any express or implied
5
* warranty. In no event will the authors be held liable for any damages
6
* arising from the use of this software.
7
* Permission is granted to anyone to use this software for any purpose,
8
* including commercial applications, and to alter it and redistribute it
9
* freely, subject to the following restrictions:
10
* 1. The origin of this software must not be misrepresented; you must not
11
* claim that you wrote the original software. If you use this software
12
* in a product, an acknowledgment in the product documentation would be
13
* appreciated but is not required.
14
* 2. Altered source versions must be plainly marked as such, and must not be
15
* misrepresented as being the original software.
16
* 3. This notice may not be removed or altered from any source distribution.
17
*/
18
19
#ifndef B2_GEAR_JOINT_H
20
#define B2_GEAR_JOINT_H
21
22
#include <Box2D/Dynamics/Joints/b2Joint.h>
23
26
struct
b2GearJointDef
:
public
b2JointDef
27
{
28
b2GearJointDef
()
29
{
30
type
= e_gearJoint;
31
joint1
= NULL;
32
joint2
= NULL;
33
ratio
= 1.0f;
34
}
35
37
b2Joint
*
joint1
;
38
40
b2Joint
*
joint2
;
41
44
float32
ratio
;
45
};
46
56
class
b2GearJoint
:
public
b2Joint
57
{
58
public
:
59
b2Vec2
GetAnchorA
()
const
;
60
b2Vec2
GetAnchorB
()
const
;
61
62
b2Vec2
GetReactionForce
(float32 inv_dt)
const
;
63
float32
GetReactionTorque
(float32 inv_dt)
const
;
64
66
b2Joint
*
GetJoint1
() {
return
m_joint1; }
67
69
b2Joint
*
GetJoint2
() {
return
m_joint2; }
70
72
void
SetRatio
(float32 ratio);
73
float32 GetRatio()
const
;
74
76
void
Dump
();
77
78
protected
:
79
80
friend
class
b2Joint
;
81
b2GearJoint
(
const
b2GearJointDef
* data);
82
83
void
InitVelocityConstraints(
const
b2SolverData
& data);
84
void
SolveVelocityConstraints(
const
b2SolverData
& data);
85
bool
SolvePositionConstraints(
const
b2SolverData
& data);
86
87
b2Joint
* m_joint1;
88
b2Joint
* m_joint2;
89
90
b2JointType m_typeA;
91
b2JointType m_typeB;
92
93
// Body A is connected to body C
94
// Body B is connected to body D
95
b2Body
* m_bodyC;
96
b2Body
* m_bodyD;
97
98
// Solver shared
99
b2Vec2
m_localAnchorA;
100
b2Vec2
m_localAnchorB;
101
b2Vec2
m_localAnchorC;
102
b2Vec2
m_localAnchorD;
103
104
b2Vec2
m_localAxisC;
105
b2Vec2
m_localAxisD;
106
107
float32 m_referenceAngleA;
108
float32 m_referenceAngleB;
109
110
float32 m_constant;
111
float32 m_ratio;
112
113
float32 m_impulse;
114
115
// Solver temp
116
int32 m_indexA, m_indexB, m_indexC, m_indexD;
117
b2Vec2
m_lcA, m_lcB, m_lcC, m_lcD;
118
float32 m_mA, m_mB, m_mC, m_mD;
119
float32 m_iA, m_iB, m_iC, m_iD;
120
b2Vec2
m_JvAC, m_JvBD;
121
float32 m_JwA, m_JwB, m_JwC, m_JwD;
122
float32 m_mass;
123
};
124
125
#endif
b2Vec2
A 2D column vector.
Definition:
b2Math.h:54
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition:
b2Body.h:127
b2GearJoint::SetRatio
void SetRatio(float32 ratio)
Set/Get the gear ratio.
Definition:
b2GearJoint.cpp:392
b2GearJoint::GetAnchorA
b2Vec2 GetAnchorA() const
Get the anchor point on bodyA in world coordinates.
Definition:
b2GearJoint.cpp:370
b2GearJointDef
Definition:
b2GearJoint.h:27
b2JointDef
Joint definitions are used to construct joints.
Definition:
b2Joint.h:75
b2JointDef::type
b2JointType type
The joint type is set automatically for concrete joint types.
Definition:
b2Joint.h:86
b2GearJoint::Dump
void Dump()
Dump joint to dmLog.
Definition:
b2GearJoint.cpp:403
b2GearJoint::GetAnchorB
b2Vec2 GetAnchorB() const
Get the anchor point on bodyB in world coordinates.
Definition:
b2GearJoint.cpp:375
b2GearJointDef::joint2
b2Joint * joint2
The second revolute/prismatic joint attached to the gear joint.
Definition:
b2GearJoint.h:40
b2GearJointDef::ratio
float32 ratio
Definition:
b2GearJoint.h:44
b2GearJoint::GetJoint1
b2Joint * GetJoint1()
Get the first joint.
Definition:
b2GearJoint.h:66
b2GearJoint::GetJoint2
b2Joint * GetJoint2()
Get the second joint.
Definition:
b2GearJoint.h:69
b2GearJointDef::joint1
b2Joint * joint1
The first revolute/prismatic joint attached to the gear joint.
Definition:
b2GearJoint.h:37
b2GearJoint
Definition:
b2GearJoint.h:57
b2SolverData
Solver Data.
Definition:
b2TimeStep.h:64
b2GearJoint::GetReactionTorque
float32 GetReactionTorque(float32 inv_dt) const
Get the reaction torque on bodyB in N*m.
Definition:
b2GearJoint.cpp:386
b2Joint
Definition:
b2Joint.h:104
b2GearJoint::GetReactionForce
b2Vec2 GetReactionForce(float32 inv_dt) const
Get the reaction force on bodyB at the joint anchor in Newtons.
Definition:
b2GearJoint.cpp:380
Generated by
1.8.20