b2GearJoint.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_GEAR_JOINT_H
00020 #define B2_GEAR_JOINT_H
00021 
00022 #include <Box2D/Dynamics/Joints/b2Joint.h>
00023 
00026 struct b2GearJointDef : public b2JointDef
00027 {
00028         b2GearJointDef()
00029         {
00030                 type = e_gearJoint;
00031                 joint1 = NULL;
00032                 joint2 = NULL;
00033                 ratio = 1.0f;
00034         }
00035 
00037         b2Joint* joint1;
00038 
00040         b2Joint* joint2;
00041 
00044         float32 ratio;
00045 };
00046 
00056 class b2GearJoint : public b2Joint
00057 {
00058 public:
00059         b2Vec2 GetAnchorA() const;
00060         b2Vec2 GetAnchorB() const;
00061 
00062         b2Vec2 GetReactionForce(float32 inv_dt) const;
00063         float32 GetReactionTorque(float32 inv_dt) const;
00064 
00066         b2Joint* GetJoint1() { return m_joint1; }
00067 
00069         b2Joint* GetJoint2() { return m_joint2; }
00070 
00072         void SetRatio(float32 ratio);
00073         float32 GetRatio() const;
00074 
00076         void Dump();
00077 
00078 protected:
00079 
00080         friend class b2Joint;
00081         b2GearJoint(const b2GearJointDef* data);
00082 
00083         void InitVelocityConstraints(const b2SolverData& data);
00084         void SolveVelocityConstraints(const b2SolverData& data);
00085         bool SolvePositionConstraints(const b2SolverData& data);
00086 
00087         b2Joint* m_joint1;
00088         b2Joint* m_joint2;
00089 
00090         b2JointType m_typeA;
00091         b2JointType m_typeB;
00092 
00093         // Body A is connected to body C
00094         // Body B is connected to body D
00095         b2Body* m_bodyC;
00096         b2Body* m_bodyD;
00097 
00098         // Solver shared
00099         b2Vec2 m_localAnchorA;
00100         b2Vec2 m_localAnchorB;
00101         b2Vec2 m_localAnchorC;
00102         b2Vec2 m_localAnchorD;
00103 
00104         b2Vec2 m_localAxisC;
00105         b2Vec2 m_localAxisD;
00106 
00107         float32 m_referenceAngleA;
00108         float32 m_referenceAngleB;
00109 
00110         float32 m_constant;
00111         float32 m_ratio;
00112 
00113         float32 m_impulse;
00114 
00115         // Solver temp
00116         int32 m_indexA, m_indexB, m_indexC, m_indexD;
00117         b2Vec2 m_lcA, m_lcB, m_lcC, m_lcD;
00118         float32 m_mA, m_mB, m_mC, m_mD;
00119         float32 m_iA, m_iB, m_iC, m_iD;
00120         b2Vec2 m_JvAC, m_JvBD;
00121         float32 m_JwA, m_JwB, m_JwC, m_JwD;
00122         float32 m_mass;
00123 };
00124 
00125 #endif


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