externals
box2d
include
box2d
b2_pulley_joint.h
Go to the documentation of this file.
1
// MIT License
2
3
// Copyright (c) 2019 Erin Catto
4
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
12
// The above copyright notice and this permission notice shall be included in all
13
// copies or substantial portions of the Software.
14
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
23
#ifndef B2_PULLEY_JOINT_H
24
#define B2_PULLEY_JOINT_H
25
26
#include "
b2_api.h
"
27
#include "
b2_joint.h
"
28
29
const
float
b2_minPulleyLength
= 2.0f;
30
33
struct
B2_API
b2PulleyJointDef
:
public
b2JointDef
34
{
35
b2PulleyJointDef
()
36
{
37
type
=
e_pulleyJoint
;
38
groundAnchorA.Set(-1.0
f
, 1.0
f
);
39
groundAnchorB.Set(1.0
f
, 1.0
f
);
40
localAnchorA.Set(-1.0
f
, 0.0
f
);
41
localAnchorB.Set(1.0
f
, 0.0
f
);
42
lengthA = 0.0f;
43
lengthB = 0.0f;
44
ratio = 1.0f;
45
collideConnected =
true
;
46
}
47
49
void
Initialize
(
b2Body
* bodyA,
b2Body
* bodyB,
50
const
b2Vec2
& groundAnchorA,
const
b2Vec2
& groundAnchorB,
51
const
b2Vec2
& anchorA,
const
b2Vec2
& anchorB,
52
float
ratio);
53
55
b2Vec2
groundAnchorA
;
56
58
b2Vec2
groundAnchorB
;
59
61
b2Vec2
localAnchorA
;
62
64
b2Vec2
localAnchorB
;
65
67
float
lengthA
;
68
70
float
lengthB
;
71
73
float
ratio
;
74
};
75
84
class
B2_API
b2PulleyJoint
:
public
b2Joint
85
{
86
public
:
87
b2Vec2
GetAnchorA
()
const override
;
88
b2Vec2
GetAnchorB
()
const override
;
89
90
b2Vec2
GetReactionForce
(
float
inv_dt)
const override
;
91
float
GetReactionTorque
(
float
inv_dt)
const override
;
92
94
b2Vec2
GetGroundAnchorA()
const
;
95
97
b2Vec2
GetGroundAnchorB()
const
;
98
100
float
GetLengthA()
const
;
101
103
float
GetLengthB()
const
;
104
106
float
GetRatio()
const
;
107
109
float
GetCurrentLengthA()
const
;
110
112
float
GetCurrentLengthB()
const
;
113
115
void
Dump
()
override
;
116
118
void
ShiftOrigin
(
const
b2Vec2
& newOrigin)
override
;
119
120
protected
:
121
122
friend
class
b2Joint
;
123
b2PulleyJoint
(
const
b2PulleyJointDef
* data);
124
125
void
InitVelocityConstraints
(
const
b2SolverData
& data)
override
;
126
void
SolveVelocityConstraints
(
const
b2SolverData
& data)
override
;
127
bool
SolvePositionConstraints
(
const
b2SolverData
& data)
override
;
128
129
b2Vec2
m_groundAnchorA
;
130
b2Vec2
m_groundAnchorB
;
131
float
m_lengthA
;
132
float
m_lengthB
;
133
134
// Solver shared
135
b2Vec2
m_localAnchorA
;
136
b2Vec2
m_localAnchorB
;
137
float
m_constant
;
138
float
m_ratio
;
139
float
m_impulse
;
140
141
// Solver temp
142
int32
m_indexA
;
143
int32
m_indexB
;
144
b2Vec2
m_uA
;
145
b2Vec2
m_uB
;
146
b2Vec2
m_rA
;
147
b2Vec2
m_rB
;
148
b2Vec2
m_localCenterA
;
149
b2Vec2
m_localCenterB
;
150
float
m_invMassA
;
151
float
m_invMassB
;
152
float
m_invIA
;
153
float
m_invIB
;
154
float
m_mass
;
155
};
156
157
#endif
b2PulleyJoint::m_indexB
int32 m_indexB
Definition:
b2_pulley_joint.h:143
b2PulleyJoint::m_localAnchorA
b2Vec2 m_localAnchorA
Definition:
b2_pulley_joint.h:135
b2Joint::SolveVelocityConstraints
virtual void SolveVelocityConstraints(const b2SolverData &data)=0
b2PulleyJoint::m_localCenterB
b2Vec2 m_localCenterB
Definition:
b2_pulley_joint.h:149
b2_minPulleyLength
const float b2_minPulleyLength
Definition:
b2_pulley_joint.h:29
b2PulleyJoint::m_lengthB
float m_lengthB
Definition:
b2_pulley_joint.h:132
b2PulleyJoint::m_lengthA
float m_lengthA
Definition:
b2_pulley_joint.h:131
b2Joint::GetReactionForce
virtual b2Vec2 GetReactionForce(float inv_dt) const =0
Get the reaction force on bodyB at the joint anchor in Newtons.
b2PulleyJointDef::ratio
float ratio
The pulley ratio, used to simulate a block-and-tackle.
Definition:
b2_pulley_joint.h:73
f
f
b2JointDef
Joint definitions are used to construct joints.
Definition:
b2_joint.h:72
B2_API
#define B2_API
Definition:
b2_api.h:49
b2PulleyJointDef::lengthA
float lengthA
The a reference length for the segment attached to bodyA.
Definition:
b2_pulley_joint.h:67
b2PulleyJoint::m_invMassB
float m_invMassB
Definition:
b2_pulley_joint.h:151
b2PulleyJointDef::localAnchorA
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition:
b2_pulley_joint.h:61
b2PulleyJoint::m_uA
b2Vec2 m_uA
Definition:
b2_pulley_joint.h:144
b2PulleyJoint::m_constant
float m_constant
Definition:
b2_pulley_joint.h:137
b2PulleyJoint::m_impulse
float m_impulse
Definition:
b2_pulley_joint.h:139
b2PulleyJointDef::localAnchorB
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition:
b2_pulley_joint.h:64
b2PulleyJoint::m_ratio
float m_ratio
Definition:
b2_pulley_joint.h:138
b2SolverData
Solver Data.
Definition:
b2_time_step.h:67
b2PulleyJoint::m_indexA
int32 m_indexA
Definition:
b2_pulley_joint.h:142
b2Vec2
A 2D column vector.
Definition:
b2_math.h:41
b2PulleyJoint
Definition:
b2_pulley_joint.h:84
b2PulleyJointDef::b2PulleyJointDef
b2PulleyJointDef()
Definition:
b2_pulley_joint.h:35
b2PulleyJoint::m_invIA
float m_invIA
Definition:
b2_pulley_joint.h:152
int32
signed int int32
Definition:
b2_types.h:28
b2Joint::GetReactionTorque
virtual float GetReactionTorque(float inv_dt) const =0
Get the reaction torque on bodyB in N*m.
b2PulleyJointDef::groundAnchorB
b2Vec2 groundAnchorB
The second ground anchor in world coordinates. This point never moves.
Definition:
b2_pulley_joint.h:58
b2Body
A rigid body. These are created via b2World::CreateBody.
Definition:
b2_body.h:128
b2Joint::GetAnchorA
virtual b2Vec2 GetAnchorA() const =0
Get the anchor point on bodyA in world coordinates.
b2PulleyJoint::m_mass
float m_mass
Definition:
b2_pulley_joint.h:154
b2Joint::InitVelocityConstraints
virtual void InitVelocityConstraints(const b2SolverData &data)=0
b2PulleyJoint::m_rB
b2Vec2 m_rB
Definition:
b2_pulley_joint.h:147
b2PulleyJoint::m_localCenterA
b2Vec2 m_localCenterA
Definition:
b2_pulley_joint.h:148
b2Joint::SolvePositionConstraints
virtual bool SolvePositionConstraints(const b2SolverData &data)=0
b2PulleyJoint::m_localAnchorB
b2Vec2 m_localAnchorB
Definition:
b2_pulley_joint.h:136
ImGui::Initialize
IMGUI_API void Initialize(ImGuiContext *context)
Definition:
imgui.cpp:3473
b2_api.h
b2PulleyJointDef::groundAnchorA
b2Vec2 groundAnchorA
The first ground anchor in world coordinates. This point never moves.
Definition:
b2_pulley_joint.h:55
b2Joint::Dump
virtual void Dump()
Dump this joint to the log file.
Definition:
b2_joint.h:151
b2PulleyJoint::m_groundAnchorA
b2Vec2 m_groundAnchorA
Definition:
b2_pulley_joint.h:129
b2PulleyJointDef::lengthB
float lengthB
The a reference length for the segment attached to bodyB.
Definition:
b2_pulley_joint.h:70
b2_joint.h
b2Joint
Definition:
b2_joint.h:110
b2Joint::GetAnchorB
virtual b2Vec2 GetAnchorB() const =0
Get the anchor point on bodyB in world coordinates.
b2Joint::ShiftOrigin
virtual void ShiftOrigin(const b2Vec2 &newOrigin)
Shift the origin for any points stored in world coordinates.
Definition:
b2_joint.h:154
b2PulleyJoint::m_rA
b2Vec2 m_rA
Definition:
b2_pulley_joint.h:146
b2PulleyJoint::m_invIB
float m_invIB
Definition:
b2_pulley_joint.h:153
b2PulleyJoint::m_groundAnchorB
b2Vec2 m_groundAnchorB
Definition:
b2_pulley_joint.h:130
e_pulleyJoint
Definition:
b2_joint.h:41
b2PulleyJointDef
Definition:
b2_pulley_joint.h:33
b2PulleyJoint::m_invMassA
float m_invMassA
Definition:
b2_pulley_joint.h:150
b2PulleyJoint::m_uB
b2Vec2 m_uB
Definition:
b2_pulley_joint.h:145
type
GLenum type
Definition:
gl.h:1033
mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:19