Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 2 vectors, U1 and V1 (from origin) in 3D space, together forming a plane P1. The vectors then both changes to U2 and V2 (still from origin) forming a new plane P2. Is there there a way to obtain the quaternion representing the rotation between P1 and P2?

share|cite|improve this question
From u1 and v1, the normal vector n1 of P1 can be obtained. From u2 and v2, the normal vector n2 of P2 can be obtained. The rotation between P1 and P2 actually is the rotation between n1 and n2. Given two vectors n1 and n2, we can find a rotation matrix R such that $n_2=Rn_1$. Then convert the rotation matrix to a quaternion. – Shiyu Aug 18 '11 at 13:58
Thanks! So simple! I should have thought of that. Why not post it as an answer? Though from N1 and N2, one can obtain the Quaternion directly without going through a rotation matrix. – Imbrondir Aug 18 '11 at 14:16
That's better. I'm more familiar with rotation matrices than quaternion. But I know they can be converted to each other:) – Shiyu Aug 19 '11 at 0:31
It's worth noting that this doesn't necessarily map the vectors $u_1$ and $v_1$ to $u_2$ and $v_2$ respectively. – Rahul Aug 19 '11 at 14:19
Hmm... you're right. Is it possible to find a quaternion that maps correctly? – Imbrondir Aug 22 '11 at 17:35
up vote 1 down vote accepted

I'll just post the full answer thanks to Shiyu in the comments. I'm an engineer and programmer, so the writing is probably not the way a mathematician would want to read it.

N1 = U1.cross(V1)
N2 = U2.cross(V2)
N1.normalize(), N2.normalize()
Vector M = N1+N2
Vector axis = M.cross(N2)
angle =
Quaternion q(w=angle, x=axis.x, y=axis.y, z=axis)
share|cite|improve this answer
This works well when the plane is rotate about an arbitary rotation. But not when the plane is rotated about the normal vector. What I mean is U1/V1 and U2/V1 are different but lie still on the same plane. In this simple case the rotation would be the angle between U1/U2 or V1/V2. In the answers above this rotation is not calculated in. How can this calculated in? – user49130 Nov 12 '12 at 12:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.