I have a general idea of using quaternions for rotating a polygon. Lets suppose I have a polygon with 3 vertices and I want to rotate their positions 45 degrees along all 3 axes x, y and z.
The question I want to get to the bottom of is what are the general steps for doing this.
These are the steps I think are necessary:
1. Convert Euler angles to quaternions,
2. Do the rotation with quaternions and
3. When I have the rotated quaternion would I need to convert back to Euler angles in order reposition the vertices?
If anyone could psuedocode this (or better) using the Irrlicht api please do so.
[SOLVED]Quaternion rotation,Conversion back to Euler angles?
-
- Posts: 226
- Joined: Wed Jan 26, 2011 5:37 pm
- Contact:
[SOLVED]Quaternion rotation,Conversion back to Euler angles?
Last edited by pandoragami on Fri Jan 17, 2014 4:33 pm, edited 1 time in total.
Re: Quaternion rotation, Conversion back to Euler angles?
Just put the vertices in a scene node and call node->setRotation(45, 45, 45).
I hope you realise that Euler angles are ambiguous. Once you apply the rotation about one axis, that affects the rotations about the other two. It is usual to apply the rotations in the order ZXY. This fits with aerodynamics.
I hope you realise that Euler angles are ambiguous. Once you apply the rotation about one axis, that affects the rotations about the other two. It is usual to apply the rotations in the order ZXY. This fits with aerodynamics.
-
- Posts: 226
- Joined: Wed Jan 26, 2011 5:37 pm
- Contact:
Re: Quaternion rotation, Conversion back to Euler angles?
mongoose7 wrote:Just put the vertices in a scene node and call node->setRotation(45, 45, 45).
I hope you realise that Euler angles are ambiguous. Once you apply the rotation about one axis, that affects the rotations about the other two. It is usual to apply the rotations in the order ZXY. This fits with aerodynamics.
So if I use
Code: Select all
node->setRotation(45, 45, 45);
-
- Posts: 66
- Joined: Sat Sep 29, 2012 11:58 am
Re: Quaternion rotation, Conversion back to Euler angles?
Generally to avoid Gimbal Lock we use quaternion class in irrlicht, for ex,
Code: Select all
vector3df eulerAngle = vector3df(45.0,45.0,45.0);
quaternion quatAngle = quaternion(eulerAngle * DEGTORAD);
vector3df gimbalFreeAngle;
quatAngle.toEuler(gimbalFreeAngle); // get the euler angle back without gimbal locks.
gimbalFreeAngle *= RADTODEG;
if(gimbalFreeAngle.X < 0)
gimbalFreeAngle.X += 360;
if(gimbalFreeAngle.Y < 0)
gimbalFreeAngle.Y += 360;
if(gimbalFreeAngle.Z < 0)
gimbalFreeAngle.Z += 360;
node->setRotation(gimbalFreeAngle);
-
- Posts: 226
- Joined: Wed Jan 26, 2011 5:37 pm
- Contact:
Re: Quaternion rotation, Conversion back to Euler angles?
@vivekSivamRP
Thanks, I'll mark this thread solved.
Thanks, I'll mark this thread solved.