View Full Version : Finding rotation vector and angle

Run-E

12-05-2003, 02:28 AM

Hi!

I'm using spherical coordinates to move an object that looks like an arrow around the origo. I want to rotate the arrow so that it always points to the origo.

How do I find the vector to rotate the arrow-object about and how do I calculate the angle of rotation?

Thanks in advance!

hello,

v1(x1,y1,z1)

v2(x2,y2,z2)

here is the calcul for the angle between this two vector :

axz= acos( ( x1*x2 + y1*y2 + z1*z2) )

( ------------------------ )

( norm(v1) * norm(v2) )

where norm(v1)=sqrt(x1^2 + y1^2 + z1^2 )

where norm(v2)=sqrt(x2^2 + y2^2 + z2^2 )

You can get the angle in the xz plane by delete all references to the y component.

I hope it will help you.....

Run-E

12-06-2003, 02:25 AM

Thanks!

Now I can calculate the angle, but i still need to know the axis to rotate about... Any suggestions?

If i were you, i would calculate the angle in the xz and yz and plane and then launch these opengl command:

glRotatef(axz,0,1,0);

glRotatef(ayz,1,0,0);

2 plane rotation are enought to rotae in space.

After these rotate the model to his position.

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.