Advertisement

[Newbie] About rotation ...

Started by April 12, 2001 04:29 PM
5 comments, last by Arlo13 23 years, 7 months ago
Hello ! I''m french, so excuse my english I want to do a rotation on the Y-axes with for center a point wich I know the coordinate. I''m developping a 3nd person game so I want to do a rotation of the level which have for center my player model coordinate. Thanks a lot ! "Software is like sex, it''''s better when it''''s free !"
"Software is like sex, it''s better when it''s free !"
I would go in a long explanation on how to do this... But instead ill recomend a site www.3dica.org there will have everything you will need to know on 3d math and programming.

Advertisement
Hi,

Well, I am not sure if this is exactly the type of answer you are looking for, so if I misunderstood your post and am off topic, my apologies.

3rd person, so I am thinking you have some kind of 2D map. Anyway, here is the concept in 2D, which can be applied to 3D with further derivation.

For point (x,y) rotated to point (x'',y''), with respect to the origin, the distance R to (x,y) is the same as to (x'',y''). It helps to draw this out on paper, on a standard coordinate system. Draw the line R (from the origin) to (x,y), and again (from origin) to (x'',y''). Call the angle between these lines a. Hence, your rotation equation becomes:

x'' = (x cos a) - (y sin a)
y'' = (x sin a) + (y cos a)

I am sure that many websites can give you the steps of the derivation, and can further show it to explain 3D, so I leave that to you. But that is the basic setup and equations. Hope that helps.

OctDev

The Tyr project is here.
Thanks a lot !
But some one have on other way to do on rotation with determinated point''s coordinate ?



"Software is like sex, it''''s better when it''''s free !"
"Software is like sex, it''s better when it''s free !"
Please help !

I want do a rotation with (x,y,z) for center !
And I want determin the x,y,z point''s coordinate.

And I don''t want used the glut librairy !
Remember, it''s a 3nd person game !

Thanks

"Software is like sex, it''''s better when it''''s free !"
"Software is like sex, it''s better when it''s free !"
(kx)(kx)vers Ø + cos Ø | (ky)(kx)vers Ø - (kz)sin Ø | (kz)(kx)vers Ø + (ky)sin Ø | 0 |
(kx)(ky)vers Ø + (kz)sin Ø | (ky)(ky)vers Ø + cos Ø | (kz)(ky)vers Ø - (kx)sin Ø | 0 |
(kx)(kz)vers Ø - (ky)sin Ø | (ky)(kz)vers Ø + (kx)sin Ø | (kz)(kz)vers Ø + cos Ø | 0 |
0 | 0 | 0 | 1 |


where "vers Ø" is equal to (1 - cos Ø).

Well, I hope that this matrix comes out right when this gets posted ...

I did some work on vector manipulation over the summer, and I had to write some library functions involving transformation matrices. The above is a homogenous 4x4 matrix that will give you a rotation matrix for any arbitrary axis (kx, ky, kz). The [4][4] element is the scaling factor. You can multiply the above matrix with a row vector or column vector with 4 elements. The first three elements should be the x,y,z coordinates you want to rotate, and the last element is the scaling factor of the vector (most likely to be 1, but it''s up to you).

Note that you can also multiply this matrix to another homogenous 4x4 matrix, and rotate the entire matrix as well. You should try to simplify the math as much as possible if you are writing code to do this for you, as it will take up a lot of processor time if you leave it up to standard matrix manipulation.

hope this helps ...

eriol
Advertisement
If this isn''t helping go check out a book on Linear Algebra at a bookstore...it should be able to give you way too much info on this and help you with eliminating excess math (i.e. reducing your equations) to speed up your engine...

--OctDev
The Tyr project is here.

This topic is closed to new replies.

Advertisement