Box2D: b2RopeJoint.h Source File

Box2D 2.3.0 A 2D Physics Engine for Games

- Main Page
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Enumerations Enumerator Macros Pages
b2RopeJoint.h
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_ROPE_JOINT_H
20 #define B2_ROPE_JOINT_H
21
22 #include <Box2D/Dynamics/Joints/b2Joint.h>
23
28 struct b2RopeJointDef : public b2JointDef
29 {
30 b2RopeJointDef()
31 {
32 type = e_ropeJoint;
33 localAnchorA.Set(-1.0f, 0.0f);
34 localAnchorB.Set(1.0f, 0.0f);
35 maxLength = 0.0f;
36 }
37
39 b2Vec2 localAnchorA;
40
42 b2Vec2 localAnchorB;
43
47 float32 maxLength;
48 };
49
58 class b2RopeJoint : public b2Joint
59 {
60 public:
61 b2Vec2 GetAnchorA() const;
62 b2Vec2 GetAnchorB() const;
63
64 b2Vec2 GetReactionForce(float32 inv_dt) const;
65 float32 GetReactionTorque(float32 inv_dt) const;
66
68 const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
69
71 const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; }
72
74 void SetMaxLength(float32 length) { m_maxLength = length; }
75 float32 GetMaxLength() const;
76
77 b2LimitState GetLimitState() const;
78
80 void Dump();
81
82 protected:
83
84 friend class b2Joint;
85 b2RopeJoint(const b2RopeJointDef* data);
86
87 void InitVelocityConstraints(const b2SolverData& data);
88 void SolveVelocityConstraints(const b2SolverData& data);
89 bool SolvePositionConstraints(const b2SolverData& data);
90
91 // Solver shared
92 b2Vec2 m_localAnchorA;
93 b2Vec2 m_localAnchorB;
94 float32 m_maxLength;
95 float32 m_length;
96 float32 m_impulse;
97
98 // Solver temp
99 int32 m_indexA;
100 int32 m_indexB;
101 b2Vec2 m_u;
102 b2Vec2 m_rA;
103 b2Vec2 m_rB;
104 b2Vec2 m_localCenterA;
105 b2Vec2 m_localCenterB;
106 float32 m_invMassA;
107 float32 m_invMassB;
108 float32 m_invIA;
109 float32 m_invIB;
110 float32 m_mass;
111 b2LimitState m_state;
112 };
113
114 #endif
b2RopeJoint
Definition: b2RopeJoint.h:58
b2RopeJoint::GetLocalAnchorA
const b2Vec2 & GetLocalAnchorA() const
The local anchor point relative to bodyA's origin.
Definition: b2RopeJoint.h:68
b2Joint
Definition: b2Joint.h:103
b2RopeJoint::Dump
void Dump()
Dump joint to dmLog.
Definition: b2RopeJoint.cpp:228
b2RopeJointDef::maxLength
float32 maxLength
Definition: b2RopeJoint.h:47
b2Vec2::Set
void Set(float32 x_, float32 y_)
Set this vector to some specified coordinates.
Definition: b2Math.h:65
b2JointDef::type
b2JointType type
The joint type is set automatically for concrete joint types.
Definition: b2Joint.h:86
b2SolverData
Solver Data.
Definition: b2TimeStep.h:63
b2RopeJoint::GetLocalAnchorB
const b2Vec2 & GetLocalAnchorB() const
The local anchor point relative to bodyB's origin.
Definition: b2RopeJoint.h:71
b2JointDef
Joint definitions are used to construct joints.
Definition: b2Joint.h:74
b2RopeJoint::SetMaxLength
void SetMaxLength(float32 length)
Set/Get the maximum length of the rope.
Definition: b2RopeJoint.h:74
b2RopeJoint::GetReactionForce
b2Vec2 GetReactionForce(float32 inv_dt) const
Get the reaction force on bodyB at the joint anchor in Newtons.
Definition: b2RopeJoint.cpp:206
b2RopeJoint::GetAnchorB
b2Vec2 GetAnchorB() const
Get the anchor point on bodyB in world coordinates.
Definition: b2RopeJoint.cpp:201
b2RopeJoint::GetReactionTorque
float32 GetReactionTorque(float32 inv_dt) const
Get the reaction torque on bodyB in N*m.
Definition: b2RopeJoint.cpp:212
b2RopeJointDef
Definition: b2RopeJoint.h:28
b2Vec2
A 2D column vector.
Definition: b2Math.h:53
b2RopeJointDef::localAnchorB
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
Definition: b2RopeJoint.h:42
b2RopeJointDef::localAnchorA
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
Definition: b2RopeJoint.h:39
b2RopeJoint::GetAnchorA
b2Vec2 GetAnchorA() const
Get the anchor point on bodyA in world coordinates.
Definition: b2RopeJoint.cpp:196