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!
here is the calcul for the angle between this two vector :
axz= acos( ( x1x2 + y1y2 + 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…
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:
2 plane rotation are enought to rotae in space.
After these rotate the model to his position.