I've got a pair of vectors. How can I create a quaternion that rotates from one to the other?
Asked
Active
Viewed 1.0k times
1 Answers
12
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.

MBo
- 77,366
- 5
- 53
- 86
-
3It might also be a good idea to normalize the rotation axis **u** after it's been computed to sustain a unit quaternion, as the cross product of two unit vectors is only normalized for orthogonal input vectors. – Christian Rau Apr 20 '12 at 09:29
-
-
9