34 #include "LinearMath/btVector3.h"
74 tgRigidInfo::initRigidBody(world);
91 std::cout <<
"creating rod with tags " << getTags() << std::endl;
103 const double radius = m_config.
radius;
106 new btCylinderShape(btVector3(radius, length / 2.0, radius));
119 const double radius = m_config.
radius;
120 const double density = m_config.
density;
121 const double volume = M_PI * radius * radius * length;
122 return volume * density;
127 const btVector3& destinationPoint)
const
134 const btVector3& destinationPoint,
135 const double rotation)
const
137 if (referencePoint == destinationPoint)
140 std::invalid_argument(
"Destination point is the reference point.");
143 const btVector3 cylinderAxis = (
getTo() -
getFrom()).normalize();
144 const btVector3 cylinderAxis2 = (
getTo() -
getFrom()).normalize();
146 const btVector3 refToDest =
147 (referencePoint - destinationPoint).normalize();
150 btVector3 rotationAxis = cylinderAxis.cross(refToDest);
153 if (rotationAxis.length() == 0.0)
155 btScalar a = cylinderAxis[0];
156 btScalar b = cylinderAxis[1];
157 btScalar c = cylinderAxis[2];
159 rotationAxis = btVector3(b - c, -a, a).normalize();
162 const btVector3 directional =
163 cylinderAxis.rotate(rotationAxis, -M_PI / 2.0).normalize();
171 const btVector3 surfaceVector = directional.rotate(cylinderAxis2, rotation).normalize()
176 return referencePoint + surfaceVector;
181 std::set<tgRigidInfo*> leaves;
187 std::set<btVector3> contained;
189 contained.insert(
getTo());
const btVector3 & getFrom() const
virtual void initRigidBody(tgWorld &world)
const double rollFriction
Definition of class tgRodInfo.
tgRodInfo(const tgRod::Config &config)
virtual btCollisionShape * getCollisionShape(tgWorld &world) const
Contains the definition of class tgWorldBulletPhysicsImpl.
virtual std::set< tgRigidInfo * > getLeafRigids()
tgRigidInfo * createRigidInfo(const tgPair &pair)
virtual std::set< btVector3 > getContainedNodes() const
virtual btVector3 getConnectionPoint(const btVector3 &referencePoint, const btVector3 &destinationPoint) const
virtual btRigidBody * getRigidBody()
btCollisionObject * m_collisionObject
tgWorldImpl & implementation() const
const btVector3 & getTo() const
void addCollisionShape(btCollisionShape *pShape)
virtual double getMass() const
btCollisionShape * m_collisionShape