Converting Euler angles in the range [-90, 90] to [0, 360]

Is it possible to convert Euler's yaw angle obtained from physical engine Bullet using

btTransform trans;
trans.getBasis().getEulerYPR(rx, ry, rz);

      

to the range [0, 360]. Otherwise for 360 degree rotation I get Euler angle varying from 0-> 90-> 0-> -90 → 0

but i want from 0-> 90-> 180-> 270-> 0

My graphics API only accepts rotation angles ranging from 0 to 360


Well, 0-> 90-> 0-> -90 was the pitch value. Here is the code I am using now:

trans.getBasis().getEulerYPR(yaw, pitch, roll);
y1 = (pitch >= 0) ? pitch : (PI2 + pitch);

      

I tried to add 180 for negative pitch values, but it doesn't work. I think I need to find another way to smoothly switch the mesh using Euler angles.


Update. It seems I shouldn't be using the bullet functions directly. The best option is to directly process the underlying matrix:

btMatrix3x3 m_el = trans.getBasis();
ry = btAtan2( m_el[0].z(), m_el[0].x() );
if(ry < 0)
    ry += SIMD_PI;

      

So this gave me a rotation around the y-axis. Now about the other 2 ... phew!

+2


source to share


1 answer


No, read domains of different angles or Euler angles in general. Two have their own domain [0, 2 pi] usually yaw and roll and one [0, pi] usually step.



0


source







All Articles