Toggle navigation
PlayRho
0.9.0
GitHub
Main Page
Modules
Classes
Files
Examples
File List
File Members
Dynamics
Joints
PulleyJoint.hpp
Go to the documentation of this file.
1
/*
2
* Original work Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
3
* Modified work Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4
*
5
* This software is provided 'as-is', without any express or implied
6
* warranty. In no event will the authors be held liable for any damages
7
* arising from the use of this software.
8
*
9
* Permission is granted to anyone to use this software for any purpose,
10
* including commercial applications, and to alter it and redistribute it
11
* freely, subject to the following restrictions:
12
*
13
* 1. The origin of this software must not be misrepresented; you must not
14
* claim that you wrote the original software. If you use this software
15
* in a product, an acknowledgment in the product documentation would be
16
* appreciated but is not required.
17
* 2. Altered source versions must be plainly marked as such, and must not be
18
* misrepresented as being the original software.
19
* 3. This notice may not be removed or altered from any source distribution.
20
*/
21
22
#ifndef PLAYRHO_DYNAMICS_JOINTS_PULLEYJOINT_HPP
23
#define PLAYRHO_DYNAMICS_JOINTS_PULLEYJOINT_HPP
24
25
#include <
PlayRho/Dynamics/Joints/Joint.hpp
>
26
#include <
PlayRho/Dynamics/Joints/PulleyJointConf.hpp
>
27
28
namespace
playrho
{
29
namespace
d2 {
30
47
class
PulleyJoint
:
public
Joint
48
{
49
public
:
50
55
PulleyJoint
(
const
PulleyJointConf
& data);
56
57
void
Accept
(
JointVisitor
& visitor)
const override
;
58
void
Accept
(
JointVisitor
& visitor)
override
;
59
Length2
GetAnchorA
()
const override
;
60
Length2
GetAnchorB
()
const override
;
61
Momentum2
GetLinearReaction
()
const override
;
62
AngularMomentum
GetAngularReaction
()
const override
;
63
bool
ShiftOrigin
(
const
Length2
newOrigin)
override
;
64
66
Length2
GetLocalAnchorA
()
const
noexcept;
67
69
Length2
GetLocalAnchorB
()
const
noexcept;
70
72
Length2
GetGroundAnchorA
()
const
noexcept;
73
75
Length2
GetGroundAnchorB
()
const
noexcept;
76
78
Length
GetLengthA
()
const
noexcept;
79
81
Length
GetLengthB
()
const
noexcept;
82
84
Real
GetRatio
()
const
noexcept;
85
86
private
:
87
88
void
InitVelocityConstraints(
BodyConstraintsMap
& bodies,
89
const
StepConf
& step,
90
const
ConstraintSolverConf
&)
override
;
91
bool
SolveVelocityConstraints(
BodyConstraintsMap
& bodies,
const
StepConf
&)
override
;
92
bool
SolvePositionConstraints(
BodyConstraintsMap
& bodies,
93
const
ConstraintSolverConf
& conf)
const override
;
94
95
Length2
m_groundAnchorA;
96
Length2
m_groundAnchorB;
97
Length2
m_localAnchorA;
98
Length2
m_localAnchorB;
99
Length
m_lengthA;
100
Length
m_lengthB;
101
Real
m_ratio;
102
Length
m_constant;
103
104
// Solver shared (between calls to InitVelocityConstraints).
105
Momentum
m_impulse = 0_Ns;
106
107
// Solver temp (recalculated every call to InitVelocityConstraints).
108
UnitVec
m_uA;
109
UnitVec
m_uB;
110
Length2
m_rA;
111
Length2
m_rB;
112
Mass
m_mass;
113
};
114
115
inline
Length2
PulleyJoint::GetLocalAnchorA
() const noexcept
116
{
117
return
m_localAnchorA;
118
}
119
120
inline
Length2
PulleyJoint::GetLocalAnchorB
() const noexcept
121
{
122
return
m_localAnchorB;
123
}
124
125
inline
Length2
PulleyJoint::GetGroundAnchorA
() const noexcept
126
{
127
return
m_groundAnchorA;
128
}
129
130
inline
Length2
PulleyJoint::GetGroundAnchorB
() const noexcept
131
{
132
return
m_groundAnchorB;
133
}
134
135
inline
Length
PulleyJoint::GetLengthA
() const noexcept
136
{
137
return
m_lengthA;
138
}
139
140
inline
Length
PulleyJoint::GetLengthB
() const noexcept
141
{
142
return
m_lengthB;
143
}
144
145
inline
Real
PulleyJoint::GetRatio
() const noexcept
146
{
147
return
m_ratio;
148
}
149
152
Length
GetCurrentLengthA
(
const
PulleyJoint
& joint);
153
156
Length
GetCurrentLengthB
(
const
PulleyJoint
& joint);
157
158
}
// namespace d2
159
}
// namespace playrho
160
161
#endif // PLAYRHO_DYNAMICS_JOINTS_PULLEYJOINT_HPP