b2_gear_joint.h
Go to the documentation of this file.
1 // MIT License
2 
3 // Copyright (c) 2019 Erin Catto
4 
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #ifndef B2_GEAR_JOINT_H
24 #define B2_GEAR_JOINT_H
25 
26 #include "b2_joint.h"
27 
32 {
34  {
35  type = e_gearJoint;
36  joint1 = nullptr;
37  joint2 = nullptr;
38  ratio = 1.0f;
39  }
40 
43 
46 
49  float ratio;
50 };
51 
61 class B2_API b2GearJoint : public b2Joint
62 {
63 public:
64  b2Vec2 GetAnchorA() const override;
65  b2Vec2 GetAnchorB() const override;
66 
67  b2Vec2 GetReactionForce(float inv_dt) const override;
68  float GetReactionTorque(float inv_dt) const override;
69 
71  b2Joint* GetJoint1() { return m_joint1; }
72 
74  b2Joint* GetJoint2() { return m_joint2; }
75 
77  void SetRatio(float ratio);
78  float GetRatio() const;
79 
81  void Dump() override;
82 
83 protected:
84 
85  friend class b2Joint;
86  b2GearJoint(const b2GearJointDef* data);
87 
88  void InitVelocityConstraints(const b2SolverData& data) override;
89  void SolveVelocityConstraints(const b2SolverData& data) override;
90  bool SolvePositionConstraints(const b2SolverData& data) override;
91 
94 
97 
98  // Body A is connected to body C
99  // Body B is connected to body D
102 
103  // Solver shared
108 
111 
114 
115  float m_constant;
116  float m_ratio;
117 
118  float m_impulse;
119 
120  // Solver temp
121  int32 m_indexA, m_indexB, m_indexC, m_indexD;
122  b2Vec2 m_lcA, m_lcB, m_lcC, m_lcD;
123  float m_mA, m_mB, m_mC, m_mD;
124  float m_iA, m_iB, m_iC, m_iD;
125  b2Vec2 m_JvAC, m_JvBD;
126  float m_JwA, m_JwB, m_JwC, m_JwD;
127  float m_mass;
128 };
129 
130 #endif
b2Vec2 m_localAxisD
virtual void SolveVelocityConstraints(const b2SolverData &data)=0
b2Joint * joint2
The second revolute/prismatic joint attached to the gear joint.
Definition: b2_gear_joint.h:45
b2Joint * m_joint2
Definition: b2_gear_joint.h:93
virtual b2Vec2 GetReactionForce(float inv_dt) const =0
Get the reaction force on bodyB at the joint anchor in Newtons.
Joint definitions are used to construct joints.
Definition: b2_joint.h:72
#define B2_API
Definition: b2_api.h:49
b2Body * m_bodyD
b2Joint * GetJoint2()
Get the second joint.
Definition: b2_gear_joint.h:74
b2JointType m_typeA
Definition: b2_gear_joint.h:95
Solver Data.
Definition: b2_time_step.h:67
A 2D column vector.
Definition: b2_math.h:41
signed int int32
Definition: b2_types.h:28
virtual float GetReactionTorque(float inv_dt) const =0
Get the reaction torque on bodyB in N*m.
A rigid body. These are created via b2World::CreateBody.
Definition: b2_body.h:128
b2Vec2 m_localAnchorB
b2Body * m_bodyC
virtual b2Vec2 GetAnchorA() const =0
Get the anchor point on bodyA in world coordinates.
b2Joint * m_joint1
Definition: b2_gear_joint.h:92
b2Vec2 m_localAnchorC
virtual void InitVelocityConstraints(const b2SolverData &data)=0
virtual bool SolvePositionConstraints(const b2SolverData &data)=0
b2Joint * joint1
The first revolute/prismatic joint attached to the gear joint.
Definition: b2_gear_joint.h:42
float m_referenceAngleA
float m_constant
b2Joint * GetJoint1()
Get the first joint.
Definition: b2_gear_joint.h:71
float m_referenceAngleB
virtual void Dump()
Dump this joint to the log file.
Definition: b2_joint.h:151
b2Vec2 m_localAnchorA
virtual b2Vec2 GetAnchorB() const =0
Get the anchor point on bodyB in world coordinates.
b2Vec2 m_localAxisC
b2JointType m_typeB
Definition: b2_gear_joint.h:96
friend class b2GearJoint
Definition: b2_joint.h:163
b2Vec2 m_localAnchorD
b2JointType
Definition: b2_joint.h:35
GLenum type
Definition: gl.h:1033


mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:19