3
$\begingroup$

I have a vector $(a,b,c)$ and another vector $(d,e,f)$. I'm trying to rotate $(a,b,c)$ so its parallel to $(d,e,f)$ using quaternions. I need help understanding how I would do this.

I have so far that a quaternion is defined as

q = w + xi + yj + zk

so then I have

q1 = 0 + ai + bj + ck
q2 = 0 + di + ej + fk

But now I'm not sure what to do next...

$\endgroup$

1 Answer 1

2
$\begingroup$

I guess by "parallel" you intend "pointing in the same direction."

We may as well rotate $(d,e,f)$ in the plane spanned by $v=(d,e,f)$ and $w=(a,b,c)$. The axis of rotation would be around a vector perpendicular to this plane such as $a=v\times w$, which you'd normalize to a unit length vector $u$. Finally, we'd need the angle of rotation $\theta$, which can be retrieved from $v\cdot w =\|v\|\|w\|\cos(\theta)$ by solving for $\theta$.

Then following the scheme for using quaternions to perform rotations, the quaternion you're looking for is $q=\cos(\theta/2)+u\sin(\theta/2)$. The transformation $x\to qxq^{-1}$ moves $v$ to point in the same direction as $w$.

$\endgroup$
4
  • $\begingroup$ I don't understand what $u$ is. I can get \theta, but then how does qxq^-1 move v? $\endgroup$
    – omega
    Apr 1, 2014 at 19:59
  • $\begingroup$ u is the quaternion representing the unit normal to the plane of rotation. It's a quaternion with real part zero just like v and w. X represents any quaternion with real part are (which represents a three dimensional real vector) v moves from v to $qvq^{-1}$ $\endgroup$
    – rschwieb
    Apr 1, 2014 at 21:32
  • $\begingroup$ I think that is just a typo: $a = v × w$ should read $u = v × w$ $\endgroup$
    – kd88
    Nov 26, 2015 at 15:57
  • 1
    $\begingroup$ @kd88 Actually the only typo was that I used both $u$ and $n$ when I meant the same thing. The point is that $a$ was not necessarily a unit vector. $\endgroup$
    – rschwieb
    Nov 27, 2015 at 2:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .