Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

For the simplicity, we'll consider two 3D points, that moves one relatively to other, in time. Let's say:

at moment t0, we have P1(0,0,0) and P2(0,2,0)
at moment t1, P1 is still (0,0,0) but P2 changed to (0,2,2).

I need to compute the rotation of P2 relatively to P1, at moment t1, represented as quaternion. From what I've understood reading about quaternions, is that, at moment t0, Q1 (representing P1) and Q2 (representing P2) will be both (0, 0, 0, 0).

But at the moment t1, Q2 will become something else (w, x, y, z). How do I calculate the Q2 at t1 moment?

I've googled a lot on this subject, but I was able to find only rotation between quaternions. I will appreciate any guidance. Thanks!

share|improve this question
    
Why did you tag this with quaternions ? –  Belgi Oct 1 '12 at 22:25
2  
Note that what you are describing is not a pure rotation. The vector p2-p1 gets longer through the rotation. –  Tpofofn Oct 2 '12 at 0:10
    
You changed your question after I answered. –  Snowball Oct 2 '12 at 1:21
    
@Tpofofn Yup, you're right ... bad example. But still let's say it's all about rotation :) –  Hubrus Oct 2 '12 at 7:41
add comment

1 Answer 1

up vote 0 down vote accepted

Note that |P2(t0)| ≠ |P2(t1)|, so you'll have to do a rotation as well as a scaling.

So the question is: convert a rotation of 45° CW and a scale factor of √2 into a single quaternion representation.

The axis-angle representation of a quaternion q is

q = S · [w ax ay az]      

with S the scale factor, ax, ay and az the axis of rotation and w the scalar part of the quaternion. A 45° CW rotation as you describe is a rotation about the positive z-axis by a negative angle (CCW is always positive), which translates into

q = S · [cos(a/2) 0 0 sin(a/2)]

with a = -45° = -45·π/180 rad. For the scale factor S — we know that

p’ = q × p × q’

with q’ the conjugate, p the original vector, p’ the new vector and × the Hamilton product. The rules of the Hamilton product imply that

(c·q) × p = c·(q × p) = (q × p)·c

for any scalar constant c, so that

(S·q) × p × (S·q’) = S²·(q × p × q’)

which means for your problem

   S² = √2
<=> S = √(√2)

so that finally,

q = √(√2) · [ cos(a/2) 0 0 sin(a/2) ]
  ≈ [ 1.0987   0.0000   0.0000   -0.45509 ]
share|improve this answer
    
Please take a look at how the TeX markup works sometime. It is really easy to pick up, and is a lot easier to look at. –  rschwieb Oct 18 '12 at 15:07
    
@rschwieb: I know how that works, it's just that I started writing this when the question was still on Stack Overflow (which doesn't use MathML). When it got migrated, I just copy-pasted and never bothered to translate it. You're welcome to :) –  Rody Oldenhuis Oct 18 '12 at 15:16
add comment

Your Answer

 
discard

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.