Yaw, Pitch, Roll transformation

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Yaw, Pitch, Roll transformation

Post by JP »

Hi all,

I've been killing myself the last few days trying to figure out how to create a transformation matrix from the yaw, pitch and roll (YPR) of an object.

Basically what I've got is the current YPR in the object's local axes and just need to render that on screen...

Does anyone have any ideas how to go about it? All the attempts I've made have either suffered gimbal lock or just not been correct such as pitching by 90 degrees means that roll is applied as yaw etc.

Spent ages on google searching for solutions but have literally found nothing of any real use!
Image Image Image
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Re: Yaw, Pitch, Roll transformation

Post by Lonesome Ducky »

Well, you can get a vector created from the rotation of the yaw and pitch, then pass that vector into a quaternion as the axis, and use the roll as the rotation.

Something like:

Code: Select all

 
                        vector3df rot(pitch,yaw,0);
                        irr::core::quaternion quat;
                        quat.fromAngleAxis(roll*DEGTORAD,rot.rotationToDirection());
                        vector3df final;
                        quat.toEuler(final);
Note, I'm not sure if this specific code actually works :lol:
Last edited by Lonesome Ducky on Fri Jul 15, 2011 8:40 am, edited 2 times in total.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Re: Yaw, Pitch, Roll transformation

Post by JP »

Very interesting... certainly worth a shot!
Image Image Image
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Re: Yaw, Pitch, Roll transformation

Post by Lonesome Ducky »

Updated my post with some (hopefully working) example code.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Re: Yaw, Pitch, Roll transformation

Post by JP »

Yeah that's way off actually lol, doesn't even remotely work xD

On the plus side I have a solution now which appears to work a treat. The approach is to not use the current YPR but to keep applying the incremental changes to a 'current rotation' quaternion. Didn't work when I tried it before but now someone else has done it for me and it's fine! Such is life!
Image Image Image
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Re: Yaw, Pitch, Roll transformation

Post by Lonesome Ducky »

I came across a topic about that on Gamedev when searching for it, but had no idea how to implement it correctly. Sorry I couldn't help, but glad you got it working :)
Post Reply