btGearConstraint.cpp

Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2012 Advanced Micro Devices, Inc.  http://bulletphysics.org
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages 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 freely, 
00009 subject to the following restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00017 
00018 #include "btGearConstraint.h"
00019 
00020 btGearConstraint::btGearConstraint(btRigidBody& rbA, btRigidBody& rbB, const btVector3& axisInA,const btVector3& axisInB, btScalar ratio)
00021 :btTypedConstraint(GEAR_CONSTRAINT_TYPE,rbA,rbB),
00022 m_axisInA(axisInA),
00023 m_axisInB(axisInB),
00024 m_ratio(ratio)
00025 {
00026 }
00027 
00028 btGearConstraint::~btGearConstraint ()
00029 {
00030 }
00031 
00032 void btGearConstraint::getInfo1 (btConstraintInfo1* info)
00033 {
00034         info->m_numConstraintRows = 1;
00035         info->nub = 1;
00036 }
00037 
00038 void btGearConstraint::getInfo2 (btConstraintInfo2* info)
00039 {
00040         btVector3 globalAxisA, globalAxisB;
00041 
00042         globalAxisA = m_rbA.getWorldTransform().getBasis()*this->m_axisInA;
00043         globalAxisB = m_rbB.getWorldTransform().getBasis()*this->m_axisInB;
00044 
00045         info->m_J1angularAxis[0] = globalAxisA[0];
00046         info->m_J1angularAxis[1] = globalAxisA[1];
00047         info->m_J1angularAxis[2] = globalAxisA[2];
00048 
00049         info->m_J2angularAxis[0] = m_ratio*globalAxisB[0];
00050         info->m_J2angularAxis[1] = m_ratio*globalAxisB[1];
00051         info->m_J2angularAxis[2] = m_ratio*globalAxisB[2];
00052 
00053 }
00054