b2WheelJoint.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_WHEEL_JOINT_H
20 #define B2_WHEEL_JOINT_H
21 
23 
30 struct b2WheelJointDef : public b2JointDef
31 {
33  {
37  localAxisA.Set(1.0f, 0.0f);
38  enableMotor = false;
39  maxMotorTorque = 0.0f;
40  motorSpeed = 0.0f;
41  frequencyHz = 2.0f;
42  dampingRatio = 0.7f;
43  }
44 
47  void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor, const b2Vec2& axis);
48 
51 
54 
57 
60 
63 
66 
69 
72 };
73 
78 class b2WheelJoint : public b2Joint
79 {
80 public:
81  b2Vec2 GetAnchorA() const;
82  b2Vec2 GetAnchorB() const;
83 
84  b2Vec2 GetReactionForce(float32 inv_dt) const;
85  float32 GetReactionTorque(float32 inv_dt) const;
86 
88  const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
89 
91  const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; }
92 
94  const b2Vec2& GetLocalAxisA() const { return m_localXAxisA; }
95 
97  float32 GetJointTranslation() const;
98 
100  float32 GetJointSpeed() const;
101 
103  bool IsMotorEnabled() const;
104 
106  void EnableMotor(bool flag);
107 
109  void SetMotorSpeed(float32 speed);
110 
112  float32 GetMotorSpeed() const;
113 
115  void SetMaxMotorTorque(float32 torque);
116  float32 GetMaxMotorTorque() const;
117 
119  float32 GetMotorTorque(float32 inv_dt) const;
120 
122  void SetSpringFrequencyHz(float32 hz);
123  float32 GetSpringFrequencyHz() const;
124 
126  void SetSpringDampingRatio(float32 ratio);
127  float32 GetSpringDampingRatio() const;
128 
130  void Dump();
131 
132 protected:
133 
134  friend class b2Joint;
135  b2WheelJoint(const b2WheelJointDef* def);
136 
137  void InitVelocityConstraints(const b2SolverData& data);
138  void SolveVelocityConstraints(const b2SolverData& data);
139  bool SolvePositionConstraints(const b2SolverData& data);
140 
143 
144  // Solver shared
149 
153 
157 
158  // Solver temp
167 
168  b2Vec2 m_ax, m_ay;
169  float32 m_sAx, m_sBx;
170  float32 m_sAy, m_sBy;
171 
175 
178 };
179 
181 {
182  return m_motorSpeed;
183 }
184 
186 {
187  return m_maxMotorTorque;
188 }
189 
191 {
192  m_frequencyHz = hz;
193 }
194 
196 {
197  return m_frequencyHz;
198 }
199 
201 {
202  m_dampingRatio = ratio;
203 }
204 
206 {
207  return m_dampingRatio;
208 }
209 
210 #endif
float32 m_invIB
Definition: b2WheelJoint.h:166
float32 m_dampingRatio
Definition: b2WheelJoint.h:142
virtual void SolveVelocityConstraints(const b2SolverData &data)=0
float32 m_maxMotorTorque
Definition: b2WheelJoint.h:154
void SetSpringFrequencyHz(float32 hz)
Set/Get the spring frequency in hertz. Setting the frequency to zero disables the spring...
Definition: b2WheelJoint.h:190
float32 GetSpringDampingRatio() const
Definition: b2WheelJoint.h:205
f
Joint definitions are used to construct joints.
Definition: b2Joint.h:74
float32 GetMaxMotorTorque() const
Definition: b2WheelJoint.h:185
float32 m_sBy
Definition: b2WheelJoint.h:170
float32 m_springImpulse
Definition: b2WheelJoint.h:152
const b2Vec2 & GetLocalAnchorB() const
The local anchor point relative to bodyB's origin.
Definition: b2WheelJoint.h:91
float32 m_motorSpeed
Definition: b2WheelJoint.h:155
void SetSpringDampingRatio(float32 ratio)
Set/Get the spring damping ratio.
Definition: b2WheelJoint.h:200
void Initialize(b2Body *bodyA, b2Body *bodyB, const b2Vec2 &anchor, const b2Vec2 &axis)
Solver Data.
Definition: b2TimeStep.h:63
void SetZero()
Set this vector to all zeros.
Definition: b2Math.h:62
float32 m_motorMass
Definition: b2WheelJoint.h:173
b2Vec2 m_localAnchorB
Definition: b2WheelJoint.h:146
A 2D column vector.
Definition: b2Math.h:53
signed int int32
Definition: b2Settings.h:31
float32 frequencyHz
Suspension frequency, zero indicates no suspension.
Definition: b2WheelJoint.h:68
float32 m_invIA
Definition: b2WheelJoint.h:165
A rigid body. These are created via b2World::CreateBody.
Definition: b2Body.h:126
float32 motorSpeed
The desired motor speed in radians per second.
Definition: b2WheelJoint.h:65
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition: b2WheelJoint.h:50
virtual void InitVelocityConstraints(const b2SolverData &data)=0
float32 m_invMassB
Definition: b2WheelJoint.h:164
float32 m_motorImpulse
Definition: b2WheelJoint.h:151
b2Vec2 localAxisA
The local translation axis in bodyA.
Definition: b2WheelJoint.h:56
b2Vec2 m_localCenterA
Definition: b2WheelJoint.h:161
float32 m_bias
Definition: b2WheelJoint.h:176
virtual bool SolvePositionConstraints(const b2SolverData &data)=0
bool enableMotor
Enable/disable the joint motor.
Definition: b2WheelJoint.h:59
const b2Vec2 & GetLocalAnchorA() const
The local anchor point relative to bodyA's origin.
Definition: b2WheelJoint.h:88
float32 GetMotorSpeed() const
Get the motor speed, usually in radians per second.
Definition: b2WheelJoint.h:180
float32 maxMotorTorque
The maximum motor torque, usually in N-m.
Definition: b2WheelJoint.h:62
b2Vec2 m_localYAxisA
Definition: b2WheelJoint.h:148
b2Vec2 m_localAnchorA
Definition: b2WheelJoint.h:145
const b2Vec2 & GetLocalAxisA() const
The local joint axis relative to bodyA.
Definition: b2WheelJoint.h:94
float32 m_gamma
Definition: b2WheelJoint.h:177
b2JointType type
The joint type is set automatically for concrete joint types.
Definition: b2Joint.h:86
float32 m_mass
Definition: b2WheelJoint.h:172
float32 m_sBx
Definition: b2WheelJoint.h:169
float32 m_frequencyHz
Definition: b2WheelJoint.h:141
float32 m_impulse
Definition: b2WheelJoint.h:150
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition: b2WheelJoint.h:53
b2Vec2 m_localCenterB
Definition: b2WheelJoint.h:162
float32 GetSpringFrequencyHz() const
Definition: b2WheelJoint.h:195
b2Body * bodyA
The first attached body.
Definition: b2Joint.h:92
float32 m_invMassA
Definition: b2WheelJoint.h:163
void Set(float32 x_, float32 y_)
Set this vector to some specified coordinates.
Definition: b2Math.h:65
float32 m_springMass
Definition: b2WheelJoint.h:174
b2Vec2 m_localXAxisA
Definition: b2WheelJoint.h:147
b2Body * bodyB
The second attached body.
Definition: b2Joint.h:95
float32 dampingRatio
Suspension damping ratio, one indicates critical damping.
Definition: b2WheelJoint.h:71
float float32
Definition: b2Settings.h:35
bool m_enableMotor
Definition: b2WheelJoint.h:156


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