Getting quaternion to rotate between two vectors
geometry, math
Solution
A unit quaternion q = cos(F)+u*sin(F) represents the rotation of vector v by the angle 2*F about axis u.
If your vectors are v and w, then we should normalize them, then calculate the angle between them as 2*F=ArcCos(Dot(v, w)). Rotation axis direction vector u = Normalize(VectorProduct(v, w)). Now we can build required rotation quaternion.
Problem
I've got a pair of vectors. How can I create a quaternion that rotates from one to the other?