b2RevoluteJoint.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_REVOLUTE_JOINT_H
20 #define B2_REVOLUTE_JOINT_H
21 
23 
36 {
38  {
40  localAnchorA.Set(0.0f, 0.0f);
41  localAnchorB.Set(0.0f, 0.0f);
42  referenceAngle = 0.0f;
43  lowerAngle = 0.0f;
44  upperAngle = 0.0f;
45  maxMotorTorque = 0.0f;
46  motorSpeed = 0.0f;
47  enableLimit = false;
48  enableMotor = false;
49  }
50 
53  void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor);
54 
57 
60 
63 
66 
69 
72 
75 
78 
82 };
83 
90 class b2RevoluteJoint : public b2Joint
91 {
92 public:
93  b2Vec2 GetAnchorA() const;
94  b2Vec2 GetAnchorB() const;
95 
97  const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
98 
100  const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; }
101 
103  float32 GetReferenceAngle() const { return m_referenceAngle; }
104 
106  float32 GetJointAngle() const;
107 
109  float32 GetJointSpeed() const;
110 
112  bool IsLimitEnabled() const;
113 
115  void EnableLimit(bool flag);
116 
118  float32 GetLowerLimit() const;
119 
121  float32 GetUpperLimit() const;
122 
124  void SetLimits(float32 lower, float32 upper);
125 
127  bool IsMotorEnabled() const;
128 
130  void EnableMotor(bool flag);
131 
133  void SetMotorSpeed(float32 speed);
134 
136  float32 GetMotorSpeed() const;
137 
139  void SetMaxMotorTorque(float32 torque);
140  float32 GetMaxMotorTorque() const { return m_maxMotorTorque; }
141 
144  b2Vec2 GetReactionForce(float32 inv_dt) const;
145 
148  float32 GetReactionTorque(float32 inv_dt) const;
149 
152  float32 GetMotorTorque(float32 inv_dt) const;
153 
155  void Dump();
156 
157 protected:
158 
159  friend class b2Joint;
160  friend class b2GearJoint;
161 
163 
167 
168  // Solver shared
173 
177 
182 
183  // Solver temp
194  b2Mat33 m_mass; // effective mass for point-to-point constraint.
195  float32 m_motorMass; // effective mass for motor/limit angular constraint.
197 };
198 
200 {
201  return m_motorSpeed;
202 }
203 
204 #endif
float32 upperAngle
The upper angle for the joint limit (radians).
const b2Vec2 & GetLocalAnchorA() const
The local anchor point relative to bodyA's origin.
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
float32 GetMotorSpeed() const
Get the motor speed in radians per second.
Joint definitions are used to construct joints.
Definition: b2Joint.h:74
bool SolvePositionConstraints(const b2SolverData &data)
void Initialize(b2Body *bodyA, b2Body *bodyB, const b2Vec2 &anchor)
b2LimitState
Definition: b2Joint.h:45
b2LimitState m_limitState
void SolveVelocityConstraints(const b2SolverData &data)
Solver Data.
Definition: b2TimeStep.h:63
float32 GetMaxMotorTorque() const
A 2D column vector.
Definition: b2Math.h:52
float32 m_referenceAngle
signed int int32
Definition: b2Settings.h:31
float32 motorSpeed
The desired motor speed. Usually in radians per second.
A 2D column vector with 3 elements.
Definition: b2Math.h:143
A rigid body. These are created via b2World::CreateBody.
Definition: b2Body.h:126
float32 GetReferenceAngle() const
Get the reference angle.
float32 referenceAngle
The bodyB angle minus bodyA angle in the reference state (radians).
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
bool enableMotor
A flag to enable the joint motor.
A 3-by-3 matrix. Stored in column-major order.
Definition: b2Math.h:256
float32 lowerAngle
The lower angle for the joint limit (radians).
bool enableLimit
A flag to enable joint limits.
float32 m_maxMotorTorque
GLuint GLuint GLsizei GLenum type
b2Body * bodyA
The first attached body.
Definition: b2Joint.h:92
void Set(float32 x_, float32 y_)
Set this vector to some specified coordinates.
Definition: b2Math.h:64
const b2Vec2 & GetLocalAnchorB() const
The local anchor point relative to bodyB's origin.
b2Body * bodyB
The second attached body.
Definition: b2Joint.h:95
float float32
Definition: b2Settings.h:35
void InitVelocityConstraints(const b2SolverData &data)
GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble f


mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:51