b2GearJoint.h
Go to the documentation of this file.
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 
23 
26 struct b2GearJointDef : public b2JointDef
27 {
29  {
30  type = e_gearJoint;
31  joint1 = NULL;
32  joint2 = NULL;
33  ratio = 1.0f;
34  }
35 
38 
41 
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 
89 
92 
93  // Body A is connected to body C
94  // Body B is connected to body D
97 
98  // Solver shared
103 
106 
109 
112 
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;
123 };
124 
125 #endif
b2Vec2 m_localAxisD
Definition: b2GearJoint.h:105
float32 m_referenceAngleA
Definition: b2GearJoint.h:107
b2Vec2 m_JvBD
Definition: b2GearJoint.h:120
virtual void SolveVelocityConstraints(const b2SolverData &data)=0
b2Joint * joint2
The second revolute/prismatic joint attached to the gear joint.
Definition: b2GearJoint.h:40
b2Joint * m_joint2
Definition: b2GearJoint.h:88
float32 m_mass
Definition: b2GearJoint.h:122
Joint definitions are used to construct joints.
Definition: b2Joint.h:74
float32 ratio
Definition: b2GearJoint.h:44
b2Body * m_bodyD
Definition: b2GearJoint.h:96
int32 m_indexD
Definition: b2GearJoint.h:116
b2Joint * GetJoint2()
Get the second joint.
Definition: b2GearJoint.h:69
float32 m_constant
Definition: b2GearJoint.h:110
float32 m_ratio
Definition: b2GearJoint.h:111
b2JointType m_typeA
Definition: b2GearJoint.h:90
Solver Data.
Definition: b2TimeStep.h:63
A 2D column vector.
Definition: b2Math.h:53
float32 m_iD
Definition: b2GearJoint.h:119
signed int int32
Definition: b2Settings.h:31
A rigid body. These are created via b2World::CreateBody.
Definition: b2Body.h:126
float32 m_mD
Definition: b2GearJoint.h:118
b2Vec2 m_localAnchorB
Definition: b2GearJoint.h:100
b2Body * m_bodyC
Definition: b2GearJoint.h:95
b2Joint * m_joint1
Definition: b2GearJoint.h:87
b2Vec2 m_localAnchorC
Definition: b2GearJoint.h:101
virtual void InitVelocityConstraints(const b2SolverData &data)=0
virtual bool SolvePositionConstraints(const b2SolverData &data)=0
b2JointType
Definition: b2Joint.h:29
b2Joint * joint1
The first revolute/prismatic joint attached to the gear joint.
Definition: b2GearJoint.h:37
float32 m_referenceAngleB
Definition: b2GearJoint.h:108
b2Joint * GetJoint1()
Get the first joint.
Definition: b2GearJoint.h:66
b2Vec2 m_localAnchorA
Definition: b2GearJoint.h:99
b2JointType type
The joint type is set automatically for concrete joint types.
Definition: b2Joint.h:86
float32 m_impulse
Definition: b2GearJoint.h:113
b2Vec2 m_localAxisC
Definition: b2GearJoint.h:104
b2JointType m_typeB
Definition: b2GearJoint.h:91
friend class b2GearJoint
Definition: b2Joint.h:156
b2Vec2 m_localAnchorD
Definition: b2GearJoint.h:102
float32 m_JwD
Definition: b2GearJoint.h:121
b2Vec2 m_lcD
Definition: b2GearJoint.h:117
float float32
Definition: b2Settings.h:35


mvsim
Author(s):
autogenerated on Thu Jun 6 2019 19:36:40