b2WeldJoint.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_WELD_JOINT_H
00020 #define B2_WELD_JOINT_H
00021 
00022 #include <Box2D/Dynamics/Joints/b2Joint.h>
00023 
00027 struct b2WeldJointDef : public b2JointDef
00028 {
00029         b2WeldJointDef()
00030         {
00031                 type = e_weldJoint;
00032                 localAnchorA.Set(0.0f, 0.0f);
00033                 localAnchorB.Set(0.0f, 0.0f);
00034                 referenceAngle = 0.0f;
00035                 frequencyHz = 0.0f;
00036                 dampingRatio = 0.0f;
00037         }
00038 
00041         void Initialize(b2Body* bodyA, b2Body* bodyB, const b2Vec2& anchor);
00042 
00044         b2Vec2 localAnchorA;
00045 
00047         b2Vec2 localAnchorB;
00048 
00050         float32 referenceAngle;
00051         
00054         float32 frequencyHz;
00055 
00057         float32 dampingRatio;
00058 };
00059 
00062 class b2WeldJoint : public b2Joint
00063 {
00064 public:
00065         b2Vec2 GetAnchorA() const;
00066         b2Vec2 GetAnchorB() const;
00067 
00068         b2Vec2 GetReactionForce(float32 inv_dt) const;
00069         float32 GetReactionTorque(float32 inv_dt) const;
00070 
00072         const b2Vec2& GetLocalAnchorA() const { return m_localAnchorA; }
00073 
00075         const b2Vec2& GetLocalAnchorB() const  { return m_localAnchorB; }
00076 
00078         float32 GetReferenceAngle() const { return m_referenceAngle; }
00079 
00081         void SetFrequency(float32 hz) { m_frequencyHz = hz; }
00082         float32 GetFrequency() const { return m_frequencyHz; }
00083 
00085         void SetDampingRatio(float32 ratio) { m_dampingRatio = ratio; }
00086         float32 GetDampingRatio() const { return m_dampingRatio; }
00087 
00089         void Dump();
00090 
00091 protected:
00092 
00093         friend class b2Joint;
00094 
00095         b2WeldJoint(const b2WeldJointDef* def);
00096 
00097         void InitVelocityConstraints(const b2SolverData& data);
00098         void SolveVelocityConstraints(const b2SolverData& data);
00099         bool SolvePositionConstraints(const b2SolverData& data);
00100 
00101         float32 m_frequencyHz;
00102         float32 m_dampingRatio;
00103         float32 m_bias;
00104 
00105         // Solver shared
00106         b2Vec2 m_localAnchorA;
00107         b2Vec2 m_localAnchorB;
00108         float32 m_referenceAngle;
00109         float32 m_gamma;
00110         b2Vec3 m_impulse;
00111 
00112         // Solver temp
00113         int32 m_indexA;
00114         int32 m_indexB;
00115         b2Vec2 m_rA;
00116         b2Vec2 m_rB;
00117         b2Vec2 m_localCenterA;
00118         b2Vec2 m_localCenterB;
00119         float32 m_invMassA;
00120         float32 m_invMassB;
00121         float32 m_invIA;
00122         float32 m_invIB;
00123         b2Mat33 m_mass;
00124 };
00125 
00126 #endif


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