Bug when converting t Euler

OSasuke
Posts: 47
Joined: Tue Dec 09, 2008 10:12 am

Bug when converting t Euler

Post by OSasuke »

Hi,

I have some problems with the conversion to euler angles.
I created a box and apply an agular velocity.

This is my code for conversion :

Code: Select all

Body->setAngularVelocity(btVector3(0,1,0));
btTransform t;
Body->getMotionState()->getWorldTransform(t);
btMatrix3x3 m(t.getRotation());
btVector3 v;
m.getEulerYPR(v[0],v[1],v[2]);
//Or m.getEulerZYX(v[0],v[1],v[2]);
//..
std::cout << v[0] << "," << v[1] << "," << v[2] << endl;

The problem is that the values are wrong.

I should have the following values :
X = 0
Y = [-180 ; 180] ( between -180 and 180 )
Z = 0

But i have this :
X = {0 ; 180} ( 0 or 180 )
Y = [-90 ; 90] ( between -90 and 90 )
Z = {0 ; 180} ( 0 or 180 )

Is there a solution to this, because i need it to build an AI (Artificial intelligence). :(
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bug when converting t Euler

Post by Erwin Coumans »

Your best bet is to convert from/to euler using your own code instead. Bullet uses quaternions/matrix representation for rotation.

You might find some conversion documents/code on this website: http://www.geometrictools.com/

Thanks,
Erwin
OSasuke
Posts: 47
Joined: Tue Dec 09, 2008 10:12 am

Re: Bug when converting t Euler

Post by OSasuke »

Thanks,

I will try to write my own code. :D