Toggle navigation
PlayRho
0.9.0
GitHub
Main Page
Modules
Classes
Files
Examples
File List
File Members
Dynamics
Joints
DistanceJoint.hpp
Go to the documentation of this file.
1
/*
2
* Original work Copyright (c) 2006-2007 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_DISTANCEJOINT_HPP
23
#define PLAYRHO_DYNAMICS_JOINTS_DISTANCEJOINT_HPP
24
25
#include <
PlayRho/Dynamics/Joints/Joint.hpp
>
26
#include <
PlayRho/Dynamics/Joints/DistanceJointConf.hpp
>
27
28
namespace
playrho
{
29
namespace
d2 {
30
40
class
DistanceJoint
:
public
Joint
41
{
42
public
:
43
45
static
bool
IsOkay
(
const
DistanceJointConf
& data) noexcept;
46
51
DistanceJoint
(
const
DistanceJointConf
& data);
52
53
void
Accept
(
JointVisitor
& visitor)
const override
;
54
void
Accept
(
JointVisitor
& visitor)
override
;
55
Length2
GetAnchorA
()
const override
;
56
Length2
GetAnchorB
()
const override
;
57
Momentum2
GetLinearReaction
()
const override
;
58
AngularMomentum
GetAngularReaction
()
const override
;
59
61
Length2
GetLocalAnchorA
() const noexcept {
return
m_localAnchorA; }
62
64
Length2
GetLocalAnchorB
() const noexcept {
return
m_localAnchorB; }
65
68
void
SetLength
(
Length
length) noexcept;
69
71
Length
GetLength
() const noexcept;
72
74
void
SetFrequency
(
NonNegative
<
Frequency
> frequency) noexcept;
75
77
NonNegative
<
Frequency
>
GetFrequency
() const noexcept;
78
80
void
SetDampingRatio
(
Real
ratio) noexcept;
81
83
Real
GetDampingRatio
() const noexcept;
84
85
private:
86
87
void
InitVelocityConstraints(
BodyConstraintsMap
& bodies, const
playrho
::
StepConf
& step,
88
const
ConstraintSolverConf
&) override;
89
bool
SolveVelocityConstraints(
BodyConstraintsMap
& bodies, const
playrho
::
StepConf
& step) override;
90
bool
SolvePositionConstraints(
BodyConstraintsMap
& bodies,
91
const
ConstraintSolverConf
& conf) const override;
92
93
Length2
m_localAnchorA;
94
Length2
m_localAnchorB;
95
Length
m_length;
96
NonNegative
<
Frequency
> m_frequency =
NonNegative
<
Frequency
>{0_Hz};
97
Real
m_dampingRatio;
98
99
// Solver shared
100
Momentum
m_impulse = 0_Ns;
101
102
// Solver temp
103
InvMass
m_invGamma;
104
LinearVelocity
m_bias;
105
Mass
m_mass;
106
UnitVec m_u;
107
Length2
m_rA;
108
Length2
m_rB;
109
};
110
111
inline
void
DistanceJoint::SetLength
(
Length
length) noexcept
112
{
113
m_length = length;
114
}
115
116
inline
Length
DistanceJoint::GetLength
() const noexcept
117
{
118
return
m_length;
119
}
120
121
inline
void
DistanceJoint::SetFrequency
(
NonNegative<Frequency>
hz) noexcept
122
{
123
m_frequency = hz;
124
}
125
126
inline
NonNegative<Frequency>
DistanceJoint::GetFrequency
() const noexcept
127
{
128
return
m_frequency;
129
}
130
131
inline
void
DistanceJoint::SetDampingRatio
(
Real
ratio) noexcept
132
{
133
m_dampingRatio = ratio;
134
}
135
136
inline
Real
DistanceJoint::GetDampingRatio
() const noexcept
137
{
138
return
m_dampingRatio;
139
}
140
141
}
// namespace d2
142
}
// namespace playrho
143
144
#endif // PLAYRHO_DYNAMICS_JOINTS_DISTANCEJOINT_HPP