Jump to content
  • Advertisement

Archived

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

HyperMan

polygon rotation

This topic is 6172 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Let N be your normal and Z = {0,0,1}
Assume N is normalized ||N|| = 1
Let U = N cross Z, and x the angle between N and Z.

cos(x) = N dot Z;
x = arc cos( N dot Z )

You can then call glRotate( -x, U )

Share this post


Link to post
Share on other sites
sorry, but i dont want to rotate it on the screen, i want to
rotate it by changing its values so that all its z-values are the same (so that the normal is 0,0,1) without deforming it.

Share this post


Link to post
Share on other sites
quote:
Original post by HyperMan
sorry, but i dont want to rotate it on the screen, i want to
rotate it by changing its values so that all its z-values are the same (so that the normal is 0,0,1) without deforming it.


That''s exactly what Fruny''s code does. Nowhere does he say that Z is a screen Z direction. He defines it to be the normal that you desire, (0,0,1). You rotate about an axis perpendicular to both your current normal N and your desired normal (which Fruny called Z). That''s axis is defined by the U vector that Fruny calculates with the cross product. And the amount you rotate is the angle that he calculates using arc cos(N dot Z). The glRotate() call updates your model view transformation matrix (in OpenGL) to cause the polygon rotation that you desire.

What glRotate() really does is to construct a rotation matrix representing a rotation of angle -x, in radians, about axis U. Then it multiplies that matrix by the current model view matrix to get the updated matrix that when applied to the vertices of your polygon results in the entire polygon being rotated, without deforming its shape.

This information is available elsewhere, in tutorials and articles. Check out the "Articles & Resources" section of this site.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!