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 
23 
31 {
33  {
35  localAnchorA.Set(0.0f, 0.0f);
36  localAnchorB.Set(0.0f, 0.0f);
37  length = 1.0f;
38  frequencyHz = 0.0f;
39  dampingRatio = 0.0f;
40  }
41 
45  const b2Vec2& anchorA, const b2Vec2& anchorB);
46 
49 
52 
55 
59 
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;
108 
112 
116 
117  // Solver shared
123 
124  // Solver temp
137 };
138 
140 {
141  m_length = length;
142 }
143 
145 {
146  return m_length;
147 }
148 
150 {
151  m_frequencyHz = hz;
152 }
153 
155 {
156  return m_frequencyHz;
157 }
158 
160 {
161  m_dampingRatio = ratio;
162 }
163 
165 {
166  return m_dampingRatio;
167 }
168 
169 #endif
GLuint GLsizei GLsizei * length
virtual void SolveVelocityConstraints(const b2SolverData &data)=0
const b2Vec2 & GetLocalAnchorB() const
The local anchor point relative to bodyB's origin.
Joint definitions are used to construct joints.
Definition: b2Joint.h:74
Solver Data.
Definition: b2TimeStep.h:63
A 2D column vector.
Definition: b2Math.h:52
signed int int32
Definition: b2Settings.h:31
A rigid body. These are created via b2World::CreateBody.
Definition: b2Body.h:126
void SetLength(float32 length)
float32 dampingRatio
The damping ratio. 0 = no damping, 1 = critical damping.
void Initialize(b2Body *bodyA, b2Body *bodyB, const b2Vec2 &anchorA, const b2Vec2 &anchorB)
virtual void InitVelocityConstraints(const b2SolverData &data)=0
void SetFrequency(float32 hz)
Set/get frequency in Hz.
virtual bool SolvePositionConstraints(const b2SolverData &data)=0
const b2Vec2 & GetLocalAnchorA() const
The local anchor point relative to bodyA's origin.
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
float32 GetFrequency() const
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
void SetDampingRatio(float32 ratio)
Set/get damping ratio.
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
float32 GetDampingRatio() const
float32 GetLength() const
GLuint GLuint GLsizei GLenum type
b2Body * bodyA
The first attached body.
Definition: b2Joint.h:92
void Set(float32 x_, float32 y_)
Set this vector to some specified coordinates.
Definition: b2Math.h:64
float32 length
The natural length between the anchor points.
b2Body * bodyB
The second attached body.
Definition: b2Joint.h:95
float float32
Definition: b2Settings.h:35
GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble f


mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:51