Hello Panagiotis,

> Sorry if this is a stupid question but I can't find how to solve this!
> Assume that a vector (x1, 0.0, 0.0) is on the x axis. Lets say that
> we have another vector (x2, y2, z2), with the same length. How can I
> find the rotations that I have to apply to the initial vector
> so that we get the second vector?

I know you got the quaternion answer to your question, and that's  
fine, but on a math-related note:


Assuming nv1 = normalize(v1) and nv2 = normalize(v2),

nv1 x nv2 (cross product) gives the normal to the plane formed by v1  
and v2. So that is the axis you must rotate v1 around to get v2.

nv1 . nv2 (dot product) gives the cosine of the angle between v1 and  
v2. So acos(nv1 . nv2) is the angle you must rotate v1 around the axis  
given above to get v2.

For OSG's vector classes, the ^ operator between two vectors gives the  
cross product (returns a vector), and the * operator between two  
vectors gives the dot product (returns a floating-point number, either  
float or double).


Of course, the quaternion method you already got and used is more  
direct, but this is something any graphics programmer should know.

Good luck,

J-S
-- 
______________________________________________________
Jean-Sebastien Guay     [EMAIL PROTECTED]
                         http://whitestar02.webhop.org/

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to