I don't really understand how they work, I found some articles about them, but they were a bit tricky to understand.
What I want to know is how would I set quaternions rotation to lets say 30 degrees on x axis and 50 degrees on y axis?
I hope that there are more alive people here in irrlicht than there are in bullet's forums
PS. please avoid posting solutions that include conversions from bullet's quaternion class to irrlicht's types.
Bullet physics, quaternion rotations.
Bullet physics, quaternion rotations.
Working on game: Marrbles (Currently stopped).
-
- Posts: 1215
- Joined: Tue Jan 09, 2007 7:03 pm
- Location: Leuven, Belgium
The hard visualization would be that a rotation quaternion is a point on a unit-hypersphere
The easy visualization is to look at a quaternion as a unit vector in 3-dimensions with a given rotation around that vector, irrlicht provides an easy way to construct quaternions like this by using quaternion::fromAngleAxis(...), so if you can convert irrlicht quaternions to bullet quaternions I assume this method would be the easiest way to define and view quaternions in general
The easy visualization is to look at a quaternion as a unit vector in 3-dimensions with a given rotation around that vector, irrlicht provides an easy way to construct quaternions like this by using quaternion::fromAngleAxis(...), so if you can convert irrlicht quaternions to bullet quaternions I assume this method would be the easiest way to define and view quaternions in general
Ok, so what I tried right now is:
doesn't seam to work, maybe the addition part is whats causing problems?
if so, how can I increase my body's current rotation?
EDIT: Nevermind fixed it with a bit of google
here's the code if anyones interested:
Code: Select all
rotateRidigBody(const btScalar & angle, const btVector3 & axis, CRigidBody * body)
{
btTransform trans=body->getCenterOfMassTransform();
btQuaternion quat,quat2;
quat=trans.getRotation();
irr::core::quaternion q;
q.fromAngleAxis(angle,utils::BtToIrrVec(axis));
quat2.setW(q.W);
quat2.setX(q.X);
quat2.setY(q.Y);
quat2.setZ(q.Z);
quat+=quat2;
trans.setRotation(quat);
body->setCenterOfMassTransform(trans);
}
if so, how can I increase my body's current rotation?
EDIT: Nevermind fixed it with a bit of google
here's the code if anyones interested:
Code: Select all
void rotateRidigBody(const btScalar & angle, const btVector3 & axis, CRigidBody * body)
{
btTransform trans;
trans=body->getWorldTransform();
btQuaternion quat,quat2;
quat2.setW(cos(angle*irr::core::DEGTORAD/2));
quat2.setX(axis.getX()*sin(angle*irr::core::DEGTORAD/2));
quat2.setY(axis.getY()*sin(angle*irr::core::DEGTORAD/2));
quat2.setZ(axis.getZ()*sin(angle*irr::core::DEGTORAD/2));
trans.setRotation(quat2*quat);
body->setWorldTransform(trans);
}
Working on game: Marrbles (Currently stopped).