Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
externals
Box2D
Box2D
Dynamics
Joints
b2DistanceJoint.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2006-2007 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_DISTANCE_JOINT_H
20
#define B2_DISTANCE_JOINT_H
21
22
#include <
Box2D/Dynamics/Joints/b2Joint.h
>
23
30
struct
b2DistanceJointDef
:
public
b2JointDef
31
{
32
b2DistanceJointDef
()
33
{
34
type
=
e_distanceJoint
;
35
localAnchorA
.
Set
(0.0
f
, 0.0
f
);
36
localAnchorB
.
Set
(0.0
f
, 0.0
f
);
37
length
= 1.0f;
38
frequencyHz
= 0.0f;
39
dampingRatio
= 0.0f;
40
}
41
44
void
Initialize
(
b2Body
*
bodyA
,
b2Body
*
bodyB
,
45
const
b2Vec2
& anchorA,
const
b2Vec2
& anchorB);
46
48
b2Vec2
localAnchorA
;
49
51
b2Vec2
localAnchorB
;
52
54
float32
length
;
55
58
float32
frequencyHz
;
59
61
float32
dampingRatio
;
62
};
63
67
class
b2DistanceJoint
:
public
b2Joint
68
{
69
public
:
70
71
b2Vec2
GetAnchorA()
const
;
72
b2Vec2
GetAnchorB()
const
;
73
76
b2Vec2
GetReactionForce(
float32
inv_dt)
const
;
77
80
float32
GetReactionTorque(
float32
inv_dt)
const
;
81
83
const
b2Vec2
&
GetLocalAnchorA
()
const
{
return
m_localAnchorA; }
84
86
const
b2Vec2
&
GetLocalAnchorB
()
const
{
return
m_localAnchorB; }
87
90
void
SetLength(
float32
length
);
91
float32
GetLength()
const
;
92
94
void
SetFrequency(
float32
hz);
95
float32
GetFrequency()
const
;
96
98
void
SetDampingRatio(
float32
ratio);
99
float32
GetDampingRatio()
const
;
100
102
void
Dump();
103
104
protected
:
105
106
friend
class
b2Joint
;
107
b2DistanceJoint
(
const
b2DistanceJointDef
*
data
);
108
109
void
InitVelocityConstraints
(
const
b2SolverData
&
data
);
110
void
SolveVelocityConstraints
(
const
b2SolverData
&
data
);
111
bool
SolvePositionConstraints
(
const
b2SolverData
&
data
);
112
113
float32
m_frequencyHz
;
114
float32
m_dampingRatio
;
115
float32
m_bias
;
116
117
// Solver shared
118
b2Vec2
m_localAnchorA
;
119
b2Vec2
m_localAnchorB
;
120
float32
m_gamma
;
121
float32
m_impulse
;
122
float32
m_length
;
123
124
// Solver temp
125
int32
m_indexA
;
126
int32
m_indexB
;
127
b2Vec2
m_u
;
128
b2Vec2
m_rA
;
129
b2Vec2
m_rB
;
130
b2Vec2
m_localCenterA
;
131
b2Vec2
m_localCenterB
;
132
float32
m_invMassA
;
133
float32
m_invMassB
;
134
float32
m_invIA
;
135
float32
m_invIB
;
136
float32
m_mass
;
137
};
138
139
inline
void
b2DistanceJoint::SetLength
(
float32
length
)
140
{
141
m_length =
length
;
142
}
143
144
inline
float32
b2DistanceJoint::GetLength
()
const
145
{
146
return
m_length;
147
}
148
149
inline
void
b2DistanceJoint::SetFrequency
(
float32
hz)
150
{
151
m_frequencyHz = hz;
152
}
153
154
inline
float32
b2DistanceJoint::GetFrequency
()
const
155
{
156
return
m_frequencyHz;
157
}
158
159
inline
void
b2DistanceJoint::SetDampingRatio
(
float32
ratio)
160
{
161
m_dampingRatio = ratio;
162
}
163
164
inline
float32
b2DistanceJoint::GetDampingRatio
()
const
165
{
166
return
m_dampingRatio;
167
}
168
169
#endif
length
GLuint GLsizei GLsizei * length
b2Joint::SolveVelocityConstraints
virtual void SolveVelocityConstraints(const b2SolverData &data)=0
e_distanceJoint
Definition:
b2Joint.h:34
b2DistanceJointDef
Definition:
b2DistanceJoint.h:30
b2DistanceJointDef::b2DistanceJointDef
b2DistanceJointDef()
Definition:
b2DistanceJoint.h:32
b2DistanceJoint::GetLocalAnchorB
const b2Vec2 & GetLocalAnchorB() const
The local anchor point relative to bodyB's origin.
Definition:
b2DistanceJoint.h:86
b2JointDef
Joint definitions are used to construct joints.
Definition:
b2Joint.h:74
b2DistanceJoint::m_gamma
float32 m_gamma
Definition:
b2DistanceJoint.h:120
b2DistanceJoint::m_rA
b2Vec2 m_rA
Definition:
b2DistanceJoint.h:128
b2DistanceJoint::m_invMassB
float32 m_invMassB
Definition:
b2DistanceJoint.h:133
b2DistanceJoint::m_rB
b2Vec2 m_rB
Definition:
b2DistanceJoint.h:129
b2DistanceJoint::m_length
float32 m_length
Definition:
b2DistanceJoint.h:122
b2SolverData
Solver Data.
Definition:
b2TimeStep.h:63
b2Vec2
A 2D column vector.
Definition:
b2Math.h:52
int32
signed int int32
Definition:
b2Settings.h:31
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition:
b2Body.h:126
b2DistanceJoint::SetLength
void SetLength(float32 length)
Definition:
b2DistanceJoint.h:139
b2DistanceJointDef::dampingRatio
float32 dampingRatio
The damping ratio. 0 = no damping, 1 = critical damping.
Definition:
b2DistanceJoint.h:61
b2DistanceJoint::m_bias
float32 m_bias
Definition:
b2DistanceJoint.h:115
b2DistanceJointDef::Initialize
void Initialize(b2Body *bodyA, b2Body *bodyB, const b2Vec2 &anchorA, const b2Vec2 &anchorB)
Definition:
b2DistanceJoint.cpp:38
b2Joint::InitVelocityConstraints
virtual void InitVelocityConstraints(const b2SolverData &data)=0
b2DistanceJoint::m_localCenterB
b2Vec2 m_localCenterB
Definition:
b2DistanceJoint.h:131
b2Joint.h
b2DistanceJoint::SetFrequency
void SetFrequency(float32 hz)
Set/get frequency in Hz.
Definition:
b2DistanceJoint.h:149
b2Joint::SolvePositionConstraints
virtual bool SolvePositionConstraints(const b2SolverData &data)=0
b2DistanceJoint::GetLocalAnchorA
const b2Vec2 & GetLocalAnchorA() const
The local anchor point relative to bodyA's origin.
Definition:
b2DistanceJoint.h:83
data
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
b2DistanceJoint::GetFrequency
float32 GetFrequency() const
Definition:
b2DistanceJoint.h:154
b2DistanceJoint::m_invIB
float32 m_invIB
Definition:
b2DistanceJoint.h:135
b2DistanceJoint::m_indexB
int32 m_indexB
Definition:
b2DistanceJoint.h:126
b2DistanceJointDef::localAnchorA
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition:
b2DistanceJoint.h:48
b2DistanceJoint::m_localCenterA
b2Vec2 m_localCenterA
Definition:
b2DistanceJoint.h:130
b2DistanceJoint::SetDampingRatio
void SetDampingRatio(float32 ratio)
Set/get damping ratio.
Definition:
b2DistanceJoint.h:159
b2DistanceJointDef::frequencyHz
float32 frequencyHz
Definition:
b2DistanceJoint.h:58
b2DistanceJointDef::localAnchorB
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition:
b2DistanceJoint.h:51
b2DistanceJoint::m_localAnchorA
b2Vec2 m_localAnchorA
Definition:
b2DistanceJoint.h:118
b2DistanceJoint::m_localAnchorB
b2Vec2 m_localAnchorB
Definition:
b2DistanceJoint.h:119
b2DistanceJoint::m_impulse
float32 m_impulse
Definition:
b2DistanceJoint.h:121
b2DistanceJoint::m_invIA
float32 m_invIA
Definition:
b2DistanceJoint.h:134
b2DistanceJoint::GetDampingRatio
float32 GetDampingRatio() const
Definition:
b2DistanceJoint.h:164
b2DistanceJoint::m_mass
float32 m_mass
Definition:
b2DistanceJoint.h:136
b2DistanceJoint::m_dampingRatio
float32 m_dampingRatio
Definition:
b2DistanceJoint.h:114
b2Joint
Definition:
b2Joint.h:103
b2DistanceJoint::m_u
b2Vec2 m_u
Definition:
b2DistanceJoint.h:127
b2DistanceJoint::m_frequencyHz
float32 m_frequencyHz
Definition:
b2DistanceJoint.h:113
b2DistanceJoint::GetLength
float32 GetLength() const
Definition:
b2DistanceJoint.h:144
type
GLuint GLuint GLsizei GLenum type
b2JointDef::bodyA
b2Body * bodyA
The first attached body.
Definition:
b2Joint.h:92
b2DistanceJoint
Definition:
b2DistanceJoint.h:67
b2DistanceJoint::m_invMassA
float32 m_invMassA
Definition:
b2DistanceJoint.h:132
b2Vec2::Set
void Set(float32 x_, float32 y_)
Set this vector to some specified coordinates.
Definition:
b2Math.h:64
b2DistanceJointDef::length
float32 length
The natural length between the anchor points.
Definition:
b2DistanceJoint.h:54
b2DistanceJoint::m_indexA
int32 m_indexA
Definition:
b2DistanceJoint.h:125
b2JointDef::bodyB
b2Body * bodyB
The second attached body.
Definition:
b2Joint.h:95
float32
float float32
Definition:
b2Settings.h:35
f
GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble f
mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:51