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!
Yaw, Pitch, Roll transformation
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
Re: Yaw, Pitch, Roll transformation
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:
Note, I'm not sure if this specific code actually works
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);
Last edited by Lonesome Ducky on Fri Jul 15, 2011 8:40 am, edited 2 times in total.
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
Re: Yaw, Pitch, Roll transformation
Updated my post with some (hopefully working) example code.
Re: Yaw, Pitch, Roll transformation
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!
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!
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
Re: Yaw, Pitch, Roll transformation
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