b2PulleyJoint.h
Go to the documentation of this file.
00001 /*
00002 * Copyright (c) 2006-2011 Erin Catto http://www.box2d.org
00003 *
00004 * This software is provided 'as-is', without any express or implied
00005 * warranty.  In no event will the authors be held liable for any damages
00006 * arising from the use of this software.
00007 * Permission is granted to anyone to use this software for any purpose,
00008 * including commercial applications, and to alter it and redistribute it
00009 * freely, subject to the following restrictions:
00010 * 1. The origin of this software must not be misrepresented; you must not
00011 * claim that you wrote the original software. If you use this software
00012 * in a product, an acknowledgment in the product documentation would be
00013 * appreciated but is not required.
00014 * 2. Altered source versions must be plainly marked as such, and must not be
00015 * misrepresented as being the original software.
00016 * 3. This notice may not be removed or altered from any source distribution.
00017 */
00018 
00019 #ifndef B2_PULLEY_JOINT_H
00020 #define B2_PULLEY_JOINT_H
00021 
00022 #include <Box2D/Dynamics/Joints/b2Joint.h>
00023 
00024 const float32 b2_minPulleyLength = 2.0f;
00025 
00028 struct b2PulleyJointDef : public b2JointDef
00029 {
00030         b2PulleyJointDef()
00031         {
00032                 type = e_pulleyJoint;
00033                 groundAnchorA.Set(-1.0f, 1.0f);
00034                 groundAnchorB.Set(1.0f, 1.0f);
00035                 localAnchorA.Set(-1.0f, 0.0f);
00036                 localAnchorB.Set(1.0f, 0.0f);
00037                 lengthA = 0.0f;
00038                 lengthB = 0.0f;
00039                 ratio = 1.0f;
00040                 collideConnected = true;
00041         }
00042 
00044         void Initialize(b2Body* bodyA, b2Body* bodyB,
00045                                         const b2Vec2& groundAnchorA, const b2Vec2& groundAnchorB,
00046                                         const b2Vec2& anchorA, const b2Vec2& anchorB,
00047                                         float32 ratio);
00048 
00050         b2Vec2 groundAnchorA;
00051 
00053         b2Vec2 groundAnchorB;
00054 
00056         b2Vec2 localAnchorA;
00057 
00059         b2Vec2 localAnchorB;
00060 
00062         float32 lengthA;
00063 
00065         float32 lengthB;
00066 
00068         float32 ratio;
00069 };
00070 
00079 class b2PulleyJoint : public b2Joint
00080 {
00081 public:
00082         b2Vec2 GetAnchorA() const;
00083         b2Vec2 GetAnchorB() const;
00084 
00085         b2Vec2 GetReactionForce(float32 inv_dt) const;
00086         float32 GetReactionTorque(float32 inv_dt) const;
00087 
00089         b2Vec2 GetGroundAnchorA() const;
00090 
00092         b2Vec2 GetGroundAnchorB() const;
00093 
00095         float32 GetLengthA() const;
00096 
00098         float32 GetLengthB() const;
00099 
00101         float32 GetRatio() const;
00102 
00104         float32 GetCurrentLengthA() const;
00105 
00107         float32 GetCurrentLengthB() const;
00108 
00110         void Dump();
00111 
00113         void ShiftOrigin(const b2Vec2& newOrigin);
00114 
00115 protected:
00116 
00117         friend class b2Joint;
00118         b2PulleyJoint(const b2PulleyJointDef* data);
00119 
00120         void InitVelocityConstraints(const b2SolverData& data);
00121         void SolveVelocityConstraints(const b2SolverData& data);
00122         bool SolvePositionConstraints(const b2SolverData& data);
00123 
00124         b2Vec2 m_groundAnchorA;
00125         b2Vec2 m_groundAnchorB;
00126         float32 m_lengthA;
00127         float32 m_lengthB;
00128         
00129         // Solver shared
00130         b2Vec2 m_localAnchorA;
00131         b2Vec2 m_localAnchorB;
00132         float32 m_constant;
00133         float32 m_ratio;
00134         float32 m_impulse;
00135 
00136         // Solver temp
00137         int32 m_indexA;
00138         int32 m_indexB;
00139         b2Vec2 m_uA;
00140         b2Vec2 m_uB;
00141         b2Vec2 m_rA;
00142         b2Vec2 m_rB;
00143         b2Vec2 m_localCenterA;
00144         b2Vec2 m_localCenterB;
00145         float32 m_invMassA;
00146         float32 m_invMassB;
00147         float32 m_invIA;
00148         float32 m_invIB;
00149         float32 m_mass;
00150 };
00151 
00152 #endif


mvsim
Author(s):
autogenerated on Thu Sep 7 2017 09:27:47