Rotate point around vector

Started by
10 comments, last by shrooboo 21 years, 5 months ago
If you''re doing rigid body dynamics where you need to rotate an object, you DO NOT want to rotate the vertices in the models on every frame! Instead you store the orientation matrix for the model. The orientation matrix is:

[ a i x ]
<br>[ c k z ]<br><br>Then you grab the column vectors (the basis of the coordinate system) by saying u=(a,b,c), v=(i,j,k), w=(x,y,z). Now let''s denote the vector you want to rotate around as r and the timestep by dt. The appropriate equations for the derivatives of u,v and w are:<br><br>u'' = r x u<br>v'' = r x v<br>w'' = r x w<br><br>(Where x denotes a crossproduct). I''m not exactly sure if the signs should be changed (to u x r, v x r and w x r), but anyway, you can check that out later. If you want to use the basic Euler''s method for computing the new basis, you compute:<br><br>u_new = u + u'' * dt<br>v_new = v + v'' * dt<br>w_new = w + w'' * dt<br><br>Then you place these back to the orientation matrix. The column vectors define the bases of the coordinate system - therefore, they should be orthogonal and have magnitude of &#111;ne. After the modifications to the matrix this rarely is the case (because of the numerical errors). You can use a procedure called Gram-Schmidt orthogonalization to fix the matrix.<br><br>The method of using a separate orientation matrix is indeed a powerful and elegant &#111;ne. When you render (or do collision detection) the models, you use this orientation matrix to find the world-coordinate-system positions of the vertices in the model. The numerical error in the system will &#111;nly slow down the rotation of the orientation matrix, but this is practically almost neglible.<br><br> - Mikko Kauppila
Advertisement
I had someone tell me elsewhere to multiply the point into a 3x3 matrix representation of the angle axis, which would return the new rotated point. Is that a good solution?

uutee, If I use my method instead of yours, I will only rotate the individual points when I am doing collision detection, so It wouldn''t technically be every frame. I am going to look into your solution though.

This topic is closed to new replies.

Advertisement