• ### Announcements

#### Archived

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

# rotation techniques

## 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;
[source]
<br><br>
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 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 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.

Tina

##### Share on other sites
Try this link on MathWorld. A picture is worth a thousand words.

• ### Forum Statistics

• Total Topics
627714
• Total Posts
2978775

• 9
• 21
• 14
• 12
• 42