Jump to content
  • Advertisement


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


rotation techniques

This topic is 5794 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

I''ve been attempting to learn different rotation methods (quaternions, euler angles, angle-axis matrices), and I have come across a sticking point (for days now actually). I found this on gametutorials.com:

// Find the new x position for the new rotated point

	vNewView.x  = (cosTheta + (1 - cosTheta) * x * x)		* vView.x;
	vNewView.x += ((1 - cosTheta) * x * y - z * sinTheta)	* vView.y;
	vNewView.x += ((1 - cosTheta) * x * z + y * sinTheta)	* vView.z;

	// Find the new y position for the new rotated point

	vNewView.y  = ((1 - cosTheta) * x * y + z * sinTheta)	* vView.x;
	vNewView.y += (cosTheta + (1 - cosTheta) * y * y)		* vView.y;
	vNewView.y += ((1 - cosTheta) * y * z - x * sinTheta)	* vView.z;

	// Find the new z position for the new rotated point

	vNewView.z  = ((1 - cosTheta) * x * z - y * sinTheta)	* vView.x;
	vNewView.z += ((1 - cosTheta) * y * z + x * sinTheta)	* vView.y;
	vNewView.z += (cosTheta + (1 - cosTheta) * z * z)		* vView.z;
and I believe they derived it from this:

| cos(b)cos(c) cos(b)sin(c) -sin(b) 0|
| sin(a)sin(b)cos(c)-cos(a)sin(c) sin(a)sin(b)sin(c)-cos(a)cos(b)|
|cos(a)sin(b)cos(c)+sin(a)sin(c) cos(a)sin(b)sin(c)-sin(a)cos(c) cos(A)cos(b) 0|
| 0 0 0 0 |
sorry that is so messy, wouldn''t all fit right. Anyways, for this paper I''m writing (for a grade) I have to know how to derive these, and this one has me stumped. Anybody know where the top formula came from????

Share this post

Link to post
Share on other sites
One other question (I''ll just ask here instead of making a new post, since it deals with the same topic). I see first person camera implementations using either, euler angles, quaternions, and matrices. Does anyone use cylindrical or sherical coordinate systems? It seems like that would make sense, and also be quite easy to do. If you have (r, theta, z), just keep r set as a constant value (you only want to have the camera see out a certain distance), theta set with the mouse (just do the dot product of the x-axis to theta, convert back to rectangular coordinates and go), and z set using the dot product of z and the x axis, convert back to rectangular and go. Or use sherical coordinates. THis seems to me it would be far faster than using matrices, not succeptible to gimbal-lock, and perhaps even easy to interpolate. Is this approach ever used? And if not, then why?

Share this post

Link to post
Share on other sites
Apart from the 1-cosTheta I found a site describing the formula to rotate around an arbitrary axis or multiple axes.


I believe the Geometry III tutorial explains about matrices and using them for rotation purposes. First singly and then as a single matrix... however, it doesn''t quite explain how it got to the single matrix but I assume its some form of multiplication of the three separate matrices.

I haven''t figured out how this arbitraty rotation is calculated myself yet so I''m currently stuck with the single rotation options for now.

Let us know if you managed to find something that explains how the new single matrix is created from the 3 single matrices.

Not much of a help but hopefully enough.


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!