b2PrismaticJoint.h
Go to the documentation of this file.
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_PRISMATIC_JOINT_H
20 #define B2_PRISMATIC_JOINT_H
21 
23 
31 {
33  {
37  localAxisA.Set(1.0f, 0.0f);
38  referenceAngle = 0.0f;
39  enableLimit = false;
40  lowerTranslation = 0.0f;
41  upperTranslation = 0.0f;
42  enableMotor = false;
43  maxMotorForce = 0.0f;
44  motorSpeed = 0.0f;
45  }
46 
49  void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor, const b2Vec2& axis);
50 
53 
56 
59 
62 
65 
68 
71 
74 
77 
80 };
81 
86 class b2PrismaticJoint : public b2Joint
87 {
88 public:
89  b2Vec2 GetAnchorA() const;
90  b2Vec2 GetAnchorB() const;
91 
92  b2Vec2 GetReactionForce(float32 inv_dt) const;
93  float32 GetReactionTorque(float32 inv_dt) const;
94 
96  const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
97 
99  const b2Vec2& GetLocalAnchorB() const { return m_localAnchorB; }
100 
102  const b2Vec2& GetLocalAxisA() const { return m_localXAxisA; }
103 
105  float32 GetReferenceAngle() const { return m_referenceAngle; }
106 
108  float32 GetJointTranslation() const;
109 
111  float32 GetJointSpeed() const;
112 
114  bool IsLimitEnabled() const;
115 
117  void EnableLimit(bool flag);
118 
120  float32 GetLowerLimit() const;
121 
123  float32 GetUpperLimit() const;
124 
126  void SetLimits(float32 lower, float32 upper);
127 
129  bool IsMotorEnabled() const;
130 
132  void EnableMotor(bool flag);
133 
135  void SetMotorSpeed(float32 speed);
136 
138  float32 GetMotorSpeed() const;
139 
141  void SetMaxMotorForce(float32 force);
142  float32 GetMaxMotorForce() const { return m_maxMotorForce; }
143 
145  float32 GetMotorForce(float32 inv_dt) const;
146 
148  void Dump();
149 
150 protected:
151  friend class b2Joint;
152  friend class b2GearJoint;
154 
155  void InitVelocityConstraints(const b2SolverData& data);
156  void SolveVelocityConstraints(const b2SolverData& data);
157  bool SolvePositionConstraints(const b2SolverData& data);
158 
159  // Solver shared
174 
175  // Solver temp
184  b2Vec2 m_axis, m_perp;
185  float32 m_s1, m_s2;
186  float32 m_a1, m_a2;
189 };
190 
192 {
193  return m_motorSpeed;
194 }
195 
196 #endif
float32 referenceAngle
The constrained angle between the bodies: bodyB_angle - bodyA_angle.
float32 GetReferenceAngle() const
Get the reference angle.
f
Joint definitions are used to construct joints.
Definition: b2Joint.h:74
bool SolvePositionConstraints(const b2SolverData &data)
b2LimitState
Definition: b2Joint.h:45
void SolveVelocityConstraints(const b2SolverData &data)
const b2Vec2 & GetLocalAnchorB() const
The local anchor point relative to bodyB's origin.
float32 upperTranslation
The upper translation limit, usually in meters.
b2Vec2 localAxisA
The local translation unit axis in bodyA.
Solver Data.
Definition: b2TimeStep.h:63
void SetZero()
Set this vector to all zeros.
Definition: b2Math.h:62
A 2D column vector.
Definition: b2Math.h:53
signed int int32
Definition: b2Settings.h:31
A 2D column vector with 3 elements.
Definition: b2Math.h:144
A rigid body. These are created via b2World::CreateBody.
Definition: b2Body.h:126
float32 GetMaxMotorForce() const
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
bool enableLimit
Enable/disable the joint limit.
void Initialize(b2Body *bodyA, b2Body *bodyB, const b2Vec2 &anchor, const b2Vec2 &axis)
A 3-by-3 matrix. Stored in column-major order.
Definition: b2Math.h:257
const b2Vec2 & GetLocalAxisA() const
The local joint axis relative to bodyA.
const b2Vec2 & GetLocalAnchorA() const
The local anchor point relative to bodyA's origin.
float32 GetMotorSpeed() const
Get the motor speed, usually in meters per second.
b2JointType type
The joint type is set automatically for concrete joint types.
Definition: b2Joint.h:86
float32 motorSpeed
The desired motor speed in radians per second.
bool enableMotor
Enable/disable the joint motor.
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
b2LimitState m_limitState
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:65
float32 lowerTranslation
The lower translation limit, usually in meters.
b2Body * bodyB
The second attached body.
Definition: b2Joint.h:95
float float32
Definition: b2Settings.h:35
void InitVelocityConstraints(const b2SolverData &data)
float32 maxMotorForce
The maximum motor torque, usually in N-m.


mvsim
Author(s):
autogenerated on Thu Jun 6 2019 19:36:40