Main Page
Namespaces
Classes
Files
File List
File Members
externals
Box2D
Box2D
Dynamics
Joints
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
22
#include <
Box2D/Dynamics/Joints/b2Joint.h
>
23
35
struct
b2RevoluteJointDef
:
public
b2JointDef
36
{
37
b2RevoluteJointDef
()
38
{
39
type
=
e_revoluteJoint
;
40
localAnchorA
.
Set
(0.0
f
, 0.0
f
);
41
localAnchorB
.
Set
(0.0
f
, 0.0
f
);
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
56
b2Vec2
localAnchorA
;
57
59
b2Vec2
localAnchorB
;
60
62
float32
referenceAngle
;
63
65
bool
enableLimit
;
66
68
float32
lowerAngle
;
69
71
float32
upperAngle
;
72
74
bool
enableMotor
;
75
77
float32
motorSpeed
;
78
81
float32
maxMotorTorque
;
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
162
b2RevoluteJoint
(
const
b2RevoluteJointDef
* def);
163
164
void
InitVelocityConstraints
(
const
b2SolverData
& data);
165
void
SolveVelocityConstraints
(
const
b2SolverData
& data);
166
bool
SolvePositionConstraints
(
const
b2SolverData
& data);
167
168
// Solver shared
169
b2Vec2
m_localAnchorA
;
170
b2Vec2
m_localAnchorB
;
171
b2Vec3
m_impulse
;
172
float32
m_motorImpulse
;
173
174
bool
m_enableMotor
;
175
float32
m_maxMotorTorque
;
176
float32
m_motorSpeed
;
177
178
bool
m_enableLimit
;
179
float32
m_referenceAngle
;
180
float32
m_lowerAngle
;
181
float32
m_upperAngle
;
182
183
// Solver temp
184
int32
m_indexA
;
185
int32
m_indexB
;
186
b2Vec2
m_rA
;
187
b2Vec2
m_rB
;
188
b2Vec2
m_localCenterA
;
189
b2Vec2
m_localCenterB
;
190
float32
m_invMassA
;
191
float32
m_invMassB
;
192
float32
m_invIA
;
193
float32
m_invIB
;
194
b2Mat33
m_mass
;
// effective mass for point-to-point constraint.
195
float32
m_motorMass
;
// effective mass for motor/limit angular constraint.
196
b2LimitState
m_limitState
;
197
};
198
199
inline
float32
b2RevoluteJoint::GetMotorSpeed
()
const
200
{
201
return
m_motorSpeed;
202
}
203
204
#endif
b2RevoluteJoint::m_rA
b2Vec2 m_rA
Definition:
b2RevoluteJoint.h:186
b2RevoluteJointDef::upperAngle
float32 upperAngle
The upper angle for the joint limit (radians).
Definition:
b2RevoluteJoint.h:71
b2RevoluteJoint::m_localAnchorB
b2Vec2 m_localAnchorB
Definition:
b2RevoluteJoint.h:170
b2RevoluteJoint::m_enableLimit
bool m_enableLimit
Definition:
b2RevoluteJoint.h:178
b2RevoluteJoint
Definition:
b2RevoluteJoint.h:90
b2RevoluteJoint::GetLocalAnchorA
const b2Vec2 & GetLocalAnchorA() const
The local anchor point relative to bodyA's origin.
Definition:
b2RevoluteJoint.h:97
b2RevoluteJointDef::localAnchorB
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition:
b2RevoluteJoint.h:59
b2RevoluteJoint::m_motorMass
float32 m_motorMass
Definition:
b2RevoluteJoint.h:195
b2RevoluteJoint::GetMotorSpeed
float32 GetMotorSpeed() const
Get the motor speed in radians per second.
Definition:
b2RevoluteJoint.h:199
f
f
b2JointDef
Joint definitions are used to construct joints.
Definition:
b2Joint.h:74
b2GearJoint::SolvePositionConstraints
bool SolvePositionConstraints(const b2SolverData &data)
Definition:
b2GearJoint.cpp:271
b2RevoluteJointDef::Initialize
void Initialize(b2Body *bodyA, b2Body *bodyB, const b2Vec2 &anchor)
Definition:
b2RevoluteJoint.cpp:36
b2LimitState
b2LimitState
Definition:
b2Joint.h:45
b2RevoluteJoint::m_lowerAngle
float32 m_lowerAngle
Definition:
b2RevoluteJoint.h:180
b2RevoluteJoint::m_limitState
b2LimitState m_limitState
Definition:
b2RevoluteJoint.h:196
b2RevoluteJoint::m_motorSpeed
float32 m_motorSpeed
Definition:
b2RevoluteJoint.h:176
b2GearJoint::SolveVelocityConstraints
void SolveVelocityConstraints(const b2SolverData &data)
Definition:
b2GearJoint.cpp:235
b2RevoluteJoint::m_invIA
float32 m_invIA
Definition:
b2RevoluteJoint.h:192
b2GearJoint
Definition:
b2GearJoint.h:56
b2RevoluteJoint::m_invMassA
float32 m_invMassA
Definition:
b2RevoluteJoint.h:190
b2SolverData
Solver Data.
Definition:
b2TimeStep.h:63
b2RevoluteJoint::GetMaxMotorTorque
float32 GetMaxMotorTorque() const
Definition:
b2RevoluteJoint.h:140
b2Vec2
A 2D column vector.
Definition:
b2Math.h:53
b2RevoluteJoint::m_localCenterA
b2Vec2 m_localCenterA
Definition:
b2RevoluteJoint.h:188
b2RevoluteJoint::m_referenceAngle
float32 m_referenceAngle
Definition:
b2RevoluteJoint.h:179
int32
signed int int32
Definition:
b2Settings.h:31
b2RevoluteJointDef::motorSpeed
float32 motorSpeed
The desired motor speed. Usually in radians per second.
Definition:
b2RevoluteJoint.h:77
e_revoluteJoint
Definition:
b2Joint.h:32
b2Vec3
A 2D column vector with 3 elements.
Definition:
b2Math.h:144
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition:
b2Body.h:126
b2RevoluteJoint::GetReferenceAngle
float32 GetReferenceAngle() const
Get the reference angle.
Definition:
b2RevoluteJoint.h:103
b2RevoluteJointDef::referenceAngle
float32 referenceAngle
The bodyB angle minus bodyA angle in the reference state (radians).
Definition:
b2RevoluteJoint.h:62
b2RevoluteJointDef::localAnchorA
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition:
b2RevoluteJoint.h:56
b2RevoluteJointDef::maxMotorTorque
float32 maxMotorTorque
Definition:
b2RevoluteJoint.h:81
b2Joint.h
b2RevoluteJoint::m_motorImpulse
float32 m_motorImpulse
Definition:
b2RevoluteJoint.h:172
b2RevoluteJoint::m_localCenterB
b2Vec2 m_localCenterB
Definition:
b2RevoluteJoint.h:189
b2RevoluteJoint::m_invMassB
float32 m_invMassB
Definition:
b2RevoluteJoint.h:191
b2RevoluteJoint::m_indexB
int32 m_indexB
Definition:
b2RevoluteJoint.h:185
b2RevoluteJointDef::enableMotor
bool enableMotor
A flag to enable the joint motor.
Definition:
b2RevoluteJoint.h:74
b2RevoluteJoint::m_mass
b2Mat33 m_mass
Definition:
b2RevoluteJoint.h:194
b2Mat33
A 3-by-3 matrix. Stored in column-major order.
Definition:
b2Math.h:257
b2Joint
Definition:
b2Joint.h:103
b2JointDef::type
b2JointType type
The joint type is set automatically for concrete joint types.
Definition:
b2Joint.h:86
b2RevoluteJoint::m_enableMotor
bool m_enableMotor
Definition:
b2RevoluteJoint.h:174
b2RevoluteJoint::m_localAnchorA
b2Vec2 m_localAnchorA
Definition:
b2RevoluteJoint.h:169
b2RevoluteJointDef::lowerAngle
float32 lowerAngle
The lower angle for the joint limit (radians).
Definition:
b2RevoluteJoint.h:68
b2RevoluteJointDef::enableLimit
bool enableLimit
A flag to enable joint limits.
Definition:
b2RevoluteJoint.h:65
b2RevoluteJoint::m_maxMotorTorque
float32 m_maxMotorTorque
Definition:
b2RevoluteJoint.h:175
b2RevoluteJointDef::b2RevoluteJointDef
b2RevoluteJointDef()
Definition:
b2RevoluteJoint.h:37
b2RevoluteJointDef
Definition:
b2RevoluteJoint.h:35
b2RevoluteJoint::m_upperAngle
float32 m_upperAngle
Definition:
b2RevoluteJoint.h:181
b2RevoluteJoint::m_impulse
b2Vec3 m_impulse
Definition:
b2RevoluteJoint.h:171
b2RevoluteJoint::m_rB
b2Vec2 m_rB
Definition:
b2RevoluteJoint.h:187
b2JointDef::bodyA
b2Body * bodyA
The first attached body.
Definition:
b2Joint.h:92
b2RevoluteJoint::m_invIB
float32 m_invIB
Definition:
b2RevoluteJoint.h:193
b2Vec2::Set
void Set(float32 x_, float32 y_)
Set this vector to some specified coordinates.
Definition:
b2Math.h:65
b2RevoluteJoint::GetLocalAnchorB
const b2Vec2 & GetLocalAnchorB() const
The local anchor point relative to bodyB's origin.
Definition:
b2RevoluteJoint.h:100
b2JointDef::bodyB
b2Body * bodyB
The second attached body.
Definition:
b2Joint.h:95
b2RevoluteJoint::m_indexA
int32 m_indexA
Definition:
b2RevoluteJoint.h:184
float32
float float32
Definition:
b2Settings.h:35
b2GearJoint::InitVelocityConstraints
void InitVelocityConstraints(const b2SolverData &data)
Definition:
b2GearJoint.cpp:131
mvsim
Author(s):
autogenerated on Thu Jun 6 2019 19:36:40