Archived

This topic is now archived and is closed to further replies.

Catfang

Need help with a rotation function!!

Recommended Posts

I am working on a project for my graphics class using GLUT, but this is a general question that is non-language-specific. I am putting all my objects into classes, so that I can use inheritance to propagate object creation. My problem is that I want to make an easy way to rotate the objects. Using three variables (pitch, roll, and yaw) seems the easiest way, but I don''t know of an easy way to make it work. Doing the rotations seperately in sequence has unwanted results, because of the coordinate change with each rotation. Can this be done with a single matrix multiplication of some kind? I read on one of Nasa''s pages that this was computed for the shuttle using a single Eigen axis rotation, but I haven''t the slightest clue as to how to make that work. I just want something that is halfway intuitive to use to rotate the objects and that I can reset easily. Any help would be greatly appeciated!! >^,,^<

Share this post


Link to post
Share on other sites
The quaterion looks like the way to go, but I am just too slow tonight to figure out how to convert:

m_pitch = 5.0
m_roll = 40.0
m_yaw = -10.0

into something like:

glPushMatrix();
glMultMatrix(some_rotation_matrix_or_quaterion);
Draw_Object();
glPopMatrix();

Share this post


Link to post
Share on other sites
The storage is used to keep record of all the rotations. Using the code you provided will result in some side effects that I am trying to avoid. For example, if m_Roll is 90, then the Y-axis has effectively become the X-axis, and the new Y-axis is the old negative X-axis. Any rotations after this (like the m_Pitch and m_Yaw) will be wrong, or at least not what I want. I want all the rotations to be independant of order or each other. Thank you for your help though!

Share this post


Link to post
Share on other sites