Quaternions part 2

posted by harrison on August 31, 2012

This will be a short post explaining why conjugation is rotation, and why the axis-angle formula works. If you didn’t see it, here’s part 1.

Why is conjugation rotation?

To see why conjugation is rotation, it is helpful to expand the multiplication (assuming q is a unit quaternion):

    \[q = cos(\frac{\theta}{2}) + sin(\frac{\theta}{2})\hat{v} \]

    \[quq^{-1} = (cos(\frac{\theta}{2}) + sin(\frac{\theta}{2})\hat{v}) u (cos(\frac{\theta}{2}) - sin(\frac{\theta}{2})\hat{v}) \]

    \[quq^{-1} = cos^2(\frac{\theta}{2})u  - cos(\frac{\theta}{2}) sin(\frac{\theta}{2}) u \hat{v} + cos(\frac{\theta}{2}) sin(\frac{\theta}{2}) \hat{v} u - sin^2(\frac{\theta}{2})\hat{v}  u  \hat{v} \]

    \[quq^{-1} = cos^2(\frac{\theta}{2})u  + cos(\frac{\theta}{2}) sin(\frac{\theta}{2}) (\hat{v}u - u \hat{v})  - sin^2(\frac{\theta}{2})\hat{v}  u  \hat{v} \]

When multiplying vectors as quaternions, notice that since the real part is 0, uv = 0 - u \cdot v + 0v + 0u + u \times v = -u \cdot v + u \times v.

    \[quq^{-1} = cos^2(\frac{\theta}{2})u  + cos(\frac{\theta}{2}) sin(\frac{\theta}{2}) ((\hat{v} \cdot u + \hat{v} \times u)- (u \cdot \hat{v} + u \times \hat{v}))  - sin^2(\frac{\theta}{2})\hat{v}  u  \hat{v} \]

    \[quq^{-1} = cos^2(\frac{\theta}{2})u  + cos(\frac{\theta}{2}) sin(\frac{\theta}{2}) (\hat{v} \times u -  u \times \hat{v})  - sin^2(\frac{\theta}{2})\hat{v}  u  \hat{v} \]

    \[quq^{-1} = cos^2(\frac{\theta}{2})u  + 2cos(\frac{\theta}{2}) sin(\frac{\theta}{2}) (\hat{v} \times u)  - sin^2(\frac{\theta}{2})\hat{v}  u  \hat{v} \]

    \[quq^{-1} = cos^2(\frac{\theta}{2})u  + 2cos(\frac{\theta}{2}) sin(\frac{\theta}{2}) (\hat{v} \times u)  - sin^2(\frac{\theta}{2})(-\hat{v} \cdot u + \hat{v} \times u)\hat{v} \]

    \[quq^{-1} = cos^2(\frac{\theta}{2})u  + 2cos(\frac{\theta}{2}) sin(\frac{\theta}{2}) (\hat{v} \times u)  - sin^2(\frac{\theta}{2})(-(\hat{v} \cdot u)\hat{v} - (\hat{v} \times u) \cdot \hat{v} + (\hat{v} \times u) \times \hat{v}) \]

    \[quq^{-1} = cos^2(\frac{\theta}{2})u  + 2cos(\frac{\theta}{2}) sin(\frac{\theta}{2}) (\hat{v} \times u)  - sin^2(\frac{\theta}{2})(-(\hat{v} \cdot u)\hat{v} + (\hat{v} \times u) \times \hat{v}) \]

To finish, we need to talk about parallel and perpendicular components of u to \hat{v}. u_\parallel = (\hat{v} \cdot u) \hat{v} and u_\perp = (\hat{v} \times u) \times \hat{v} . Notice that u_\parallel + u_\perp = u.

    \[quq^{-1} = cos^2(\frac{\theta}{2})u  + 2cos(\frac{\theta}{2}) sin(\frac{\theta}{2}) (\hat{v} \times u)  - sin^2(\frac{\theta}{2})(-u_\parallel + u_\perp) \]

    \[quq^{-1} = cos^2(\frac{\theta}{2})u  + 2cos(\frac{\theta}{2}) sin(\frac{\theta}{2}) (\hat{v} \times u)  - sin^2(\frac{\theta}{2})(-2 u_\parallel + u ) \]

    \[quq^{-1} = (cos^2(\frac{\theta}{2}) - sin^2(\frac{\theta}{2}))u  + 2cos(\frac{\theta}{2}) sin(\frac{\theta}{2}) (\hat{v} \times u)  + sin^2(\frac{\theta}{2})(2 u_\parallel) \]

And now we can start using trig to get rid of those half angles:

    \[quq^{-1} = (\frac{1+cos(\theta)}{2} - \frac{1-cos(\theta)}{2})u  + sin(\theta) (\hat{v} \times u)  + (1-cos(\theta)) u_\parallel \]

    \[quq^{-1} = cos(\theta)}u  + sin(\theta) (\hat{v} \times u)  + (1-cos(\theta)) u_\parallel \]

    \[quq^{-1} = cos(\theta)}(u - u_\parallel)  + sin(\theta) (\hat{v} \times u)  +  u_\parallel \]

    \[quq^{-1} = cos(\theta)}u_\perp  + sin(\theta) (\hat{v} \times u)  +  u_\parallel \]

From here, you can see that the parallel component remains unchanged, as expected. Also, notice that u_\perp is just \hat{v} \times u rotated -\frac{\pi}{2} around \hat{v}, So you can see that the perpendicular part is being rotated around \hat{v} by \theta.

 

next time: exponentials, logs, and slerp


Twisted Oak Studios offers consulting and development on high-tech interactive projects. Check out our portfolio, or Give us a shout if you have anything you think some really rad engineers should help you with.

Archive

More interesting posts (26 of 33 articles)

Or check out our Portfolio.