# Quaternion for 3D FPS Camera

1. Oct 19, 2009

### sarah2529

I'm trying to look how the formula made on this http://www.gamedev.net/reference/programming/features/quatcam/page2.asp" [Broken]. I want to know how this formula was derived. I tried to look on Quaternions and Rotation Sequences book but they use sin/cos which is so different on this.

N.w = a.w*b.w - a.x*b.x - a.y*b.y - a.z*b.z
N.x = a.w*b.x + a.x*b.w + a.y*b.z - a.z*b.y
N.y = a.w*b.y - a.x*b.z + a.y*b.w + a.z*b.x
N.z = a.w*b.z + a.x*b.y - a.y*b.x + a.z*b.w

or maybe I'm lost?

Last edited by a moderator: May 4, 2017
2. Oct 19, 2009

### D H

Staff Emeritus
The quaternions form a number system under which addition and multiplication are each closed and associative. Addition is commutative in the quaternions but multiplication is not. There are many ways to look at quaternions as a whole. One view is that a quaternion comprises four real numbers under which multiplication is defined as in the original post. Another view, Hamilton's view, is that a quaternion comprises a real part and three distinct imaginary parts. Yet another is that a quaternion comprise a scalar real part and a vectorial (three vector) imaginary part: $Q=(q_s, \mathbf q_v)$.

Denoting two quaternions as $Q_1=(q_{1s}, \mathbf q_{1v}), Q_2 = (q_{2s}, \mathbf q_{2v})$ then the quaternion product $Q_1Q_2$ can be written using the vector dot and cross products as

$$Q_1Q_2 = (q_{1s}q_{2s} - \mathbf q_{1v}\cdot\mathbf q_{2v},\;\; q_{1s}\mathbf q_{2v} + q_{2s}\mathbf q_{1v} + \mathbf q_{1v}\times\mathbf q_{2v})$$

The book Quaternions and Rotation Sequences primarily focuses on unit quaternions. While the unit quaternions are useful (very useful) for representing rotations and transformation, there is a lot more to the quaternions than just the unit quaternions.

3. Oct 20, 2009

### sarah2529

Read it many times but I still didn't understand some of the things you've said. I just don't get it how it is made.

Anyway, do you know what's the pre-requisite for quaternion topics? Is it Linear Algebra? Because I don't understand most of the topics in the book Quaternions and Rotation Sequences. Maybe I jump ahead so fast.

4. Oct 20, 2009

### D H

Staff Emeritus

Some more detailed questions:
Do you understand complex numbers?
Do you understand Euler's identity $\exp(i\theta) = \cos \theta + i\sin\theta$?
How much do you know about real and complex analysis?
How much do you know about linear algebra?

5. Oct 20, 2009

### sarah2529

I guess so.

Nope. What's that?

Yes, I'm taking Calculus 2 class right now.

So little. But I know how to use row reduced in matrices. Thanks to the opencourseware.

Basing on what you've asked, I really did jump so fast. So what would you recommend to me? I really want to understand those quaternions for my 3D First Person Camera Engine.

6. Oct 20, 2009

### D H

Staff Emeritus
That response means you do not really understand complex numbers.

Whoa, Sarah!

Here's a sequence in an undergrad math curriculum: Calculus I & II, Ordinary differential equations, Multivariable calculus, Introduction to analysis, Linear algebra, Real analysis, Complex analysis, Calculus of variations, Differential geometry, Abstract algebra (I, II, & III !!), General topology, Geometric topology, Algebraic topology, ...

You'll run across the quaternions in the second or third abstract algebra class. You'll find out why they are useful for representing rotations when you take algebraic topology. Trying to understand quaternions when you have not yet finished Calc 2 is jumping the gun. Without the requisite intermediate knowledge all you will have will be a bunch of formulae that just don't make much sense.

As a test, see how much sense you can make of this Wikipedia article: http://en.wikipedia.org/wiki/Charts_on_SO(3)

If you insist on jumping the gun, I suggest checking out a text on abstract algebra or modern algebra. Mine gets to the quaternions on page 503.

Last edited: Oct 20, 2009
7. Oct 20, 2009

### sarah2529

OMG. I'm jumping so far. Do I really need to take "Introduction to analysis->......->Differential geometry" for me to understand Abstract algebra very much? Well I hope I can do that by myself because my curriculum only has until Multivariable calculus (I'm studying Multivariable calculus some time. Vectors... Matrices.. 18.02 in MIT opencourseware helps me so much.).

Curriculum here sucks so bad. I'm doom! I'm 18 and I barely know Multivariate calculus. Am I a failure? lol

Honestly, I really thought Calculus 2 is enough to learn quaternions. I guess I need to finish the lecture notes I found for multivariate so I can move to the next math.

Btw, thanks for the help. Now I realized that my knowledge in math is not enough for my target thesis project.

Last edited: Oct 20, 2009
8. Oct 20, 2009