30 #include "btBulletDynamicsCommon.h"
31 #include "LinearMath/btQuaternion.h"
32 #include "LinearMath/btTransform.h"
33 #include "LinearMath/btVector3.h"
55 return btVector3(0.0, 1.0, 0.0);
73 inline static btVector3
center(
const btVector3& start,
76 return (start + end) / 2.0;
89 inline static btTransform
getTransform(
const btVector3& startOrientation,
90 const btVector3& start,
94 const btVector3 origin =
center(start, end);
95 btTransform t = btTransform();
109 const btVector3& end)
153 const btVector3 norm = axis.cross(target);
155 axis.rotate(norm, (M_PI / 2.0));
171 return from.distance(to) < pow(10.0, (precision < 0 ? 5 : -precision));
192 result = btQuaternion::getIdentity();
197 const btVector3 arb =
199 const btVector3 c = (a.cross(arb)).normalize();
200 result = btQuaternion(c, M_PI).normalize();;
203 const btVector3 c = (a.cross(b)).normalize();
207 result = btQuaternion(c, acos(a.dot(b))).normalize();
222 arb = btVector3(rand()%10, rand()%10, rand()%10).normalize();
223 }
while (arb == v || arb == -v);
231 const btVector3& fixedPoint,
232 const btVector3& axis,
236 btVector3 relative = v - fixedPoint;
239 btVector3 rotated = relative.rotate(axis, angle);
242 v.setX(fixedPoint.x() + rotated.x());
243 v.setY(fixedPoint.y() + rotated.y());
244 v.setZ(fixedPoint.z() + rotated.z());
251 const btVector3& fixedPoint,
252 const btVector3& fromOrientation,
253 const btVector3& toOrientation)
263 const btVector3& fixedPoint,
264 const btQuaternion& rotation)
266 addRotation(v, fixedPoint, rotation.getAxis(), rotation.getAngle());
278 return radians * 180.0 / M_PI;
289 return degrees * (M_PI / 180.0);
299 inline static std::string
strDeg(
double degrees) {
300 std::ostringstream s;
306 inline static double round(
double d,
int precision = 5)
308 const double base = 10.0;
309 const int m =
static_cast<int>(pow(base, precision));
310 return floor(d * m + 0.5)/m;
325 os <<
"btQuaternion( "
326 << q.x() <<
", " << q.y() <<
", " << q.z() <<
", " << q.w()
341 os <<
"btVector3( " << v.x() <<
", " << v.y() <<
", " << v.z() <<
" )";
355 os <<
"btTransform: origin = " << xf.getOrigin()
356 <<
"; rotation = " << xf.getRotation();
370 os <<
"btRigidBody: " << rb.getCollisionShape();
384 os <<
"btCollisionShape: " << cs.getShapeType();
398 os <<
"btCompoundShape: " << cs.getShapeType() << std::endl
399 <<
" # Children: " << cs.getNumChildShapes() << std::endl;
Definition of abstract class tgRigidInfo.
std::ostream & operator<<(std::ostream &os, const btQuaternion &q)
static btVector3 getVector(const btVector3 &from, const btVector3 &to)
static btVector3 getArbitraryNonParallelVector(btVector3 v)
static std::string degSymbol()
static bool almostEqual(const btVector3 &from, const btVector3 &to, int precision=5)
static btQuaternion getQuaternionBetween(btVector3 a, btVector3 b)
static btVector3 upVector()
static void addRotation(btVector3 &v, const btVector3 &fixedPoint, const btVector3 &fromOrientation, const btVector3 &toOrientation)
static double deg2rad(double degrees)
static btVector3 center(const btVector3 &start, const btVector3 &end)
static void addRotation(btVector3 &v, const btVector3 &fixedPoint, const btQuaternion &rotation)
static btVector3 getRadiusVector(btVector3 axis, double radius, btVector3 target)
static btTransform getTransform(const btVector3 &startOrientation, const btVector3 &start, const btVector3 &end)
static btTransform getTransform(const btVector3 &start, const btVector3 &end)
static std::string strDeg(double degrees)
static void addRotation(btVector3 &v, const btVector3 &fixedPoint, const btVector3 &axis, double angle)
static double rad2deg(double radians)