Skip to content

On the Origin of Cross Products

07-Mar-10

On the web I’ve often seen people ask where the cross product comes from. Often they get back the formula with no explanation, or a proof of the determinant form having the desired properties. This might be useful for mathematicians or physicists, but the value of a 3×3 determinant is something I need to manually compute even less often than cross products.

Some might be happy to take the definition as is and commit it to memory, but I prefer to save my brain space for more complicated topics. Instead I have a derivation I use when I need to pull out the formula for the cross product, which only uses things I already know.

One place the cross product appears is in quaternion multiplication so we’ll start from there. Don’t fret if you don’t know anything about quaternions since not much is needed for this purpose. Everything you need to know about them for this should be covered in this post.

One common method of writing a quaternion is

Q = (w, \mathbf{v})

where w is a scalar value, and \mathbf{v} is a 3D vector. Given this representation, the multiplication of two quaternions can be written as

Q_1 Q_2 = (w_1w_2 - \mathbf{v_1} \cdot \mathbf{v_2}, w_1 \mathbf{v_2} + w_2 \mathbf{v_1} + \mathbf{v_1} \times \mathbf{v_2})

Where {}\cdot{} and {}\times{} are the regular vector dot and cross products.

Using this we can “promote” a vector to a quaternion by writing it as

Q_v = (0, \mathbf{v})

Multiplying two vectors as quaternions in this form then looks like

Q_1 Q_2 = (-\mathbf{v_1} \cdot \mathbf{v_2}, \mathbf{v_1} \times \mathbf{v_2})

So the vector part of the product of two vectors “promoted” to quaternions is the cross product of the vectors. Well how does that get us any closer to knowing the formula for the cross product?

The derivation of the quaternion product is actually fairly straight forward as well, but we need a (simple) formula given to us by Hamilton. We can write our quaternion as a real number part plus products of three imaginary values \mathbf{i}, \mathbf{j}, \mathbf{k} with the property \mathbf{i}^2 = \mathbf{j}^2 = \mathbf{k}^2 = \mathbf{ijk} = -1.

Then if we have two quaternions Q_1 and Q_2 written as

Q_1 = w_1 + x_1\mathbf{i} + y_1\mathbf{j} + z_1\mathbf{k}

Q_2 = w_2 + x_2\mathbf{i} + y_2\mathbf{j} + z_2\mathbf{k}

We can multiply these in the same fashion as regular polynomials except treating \mathbf{i}, \mathbf{j}, \mathbf{k} as not commutative under multiplication. To be completely verbose this looks like

\begin{array}{rcl}Q_1 Q_2 &=& (w_1 + x_1\mathbf{i} + y_1\mathbf{j} + z_1\mathbf{k}) (w_2 + x_2\mathbf{i} + y_2\mathbf{j} + z_2\mathbf{k})\\&=& w_1 (w_2 + x_2\mathbf{i} + y_2\mathbf{j} + z_2\mathbf{k}) + {} \\&& x_1\mathbf{i} (w_2 + x_2\mathbf{i} + y_2\mathbf{j} + z_2\mathbf{k}) + {} \\&& y_1\mathbf{j} (w_2 + x_2\mathbf{i} + y_2\mathbf{j} + z_2\mathbf{k}) + {} \\&& z_1\mathbf{k}  (w_2 + x_2\mathbf{i} + y_2\mathbf{j} + z_2\mathbf{k})\end{array}

Next distribute, and rearrange constants to a more pleasing form. As noted above it is important to not treat \mathbf{i}, \mathbf{j}, \mathbf{k} as commutative.

\begin{array}{rcl}Q_1 Q_2 &=& w_1w_2 + w_1x_2\mathbf{i} + w_1y_2\mathbf{j} + w_1z_2\mathbf{k} + {}\\&& x_1w_2\mathbf{i} + x_1x_2\mathbf{i}^2 + x_1y_2\mathbf{ij} + x_1z_2\mathbf{ik} + {}\\&& y_1w_2\mathbf{j} + y_1x_2\mathbf{ji} + y_1y_2\mathbf{j}^2 + y_1z_2\mathbf{jk} + {}\\&& z_1w_2\mathbf{k} + z_1x_2\mathbf{ki} + z_1y_2\mathbf{kj} + z_1z_2\mathbf{k}^2\end{array}

This looks like a complete train wreck, but at this point we can make use of our quaternion equation from before to clean things up. Again being quite explicit this changes the above into

\begin{array}{rcl}Q_1 Q_2 &=& w_1w_2 + w_1x_2\mathbf{i} + w_1y_2\mathbf{j} + w_1z_2\mathbf{k} +{}\\&& x_1w_2\mathbf{i} + x_1x_2(-1) + x_1y_2(\mathbf{k}) + x_1z_2(\mathbf{-j}) +{}\\&& y_1w_2\mathbf{j} + y_1x_2(\mathbf{-k}) + y_1y_2(-1) + y_1z_2(\mathbf{i}) +{}\\&& z_1w_2\mathbf{k} + z_1x_2(\mathbf{j}) + z_1y_2(\mathbf{-i}) + z_1z_2(-1)\end{array}

Now rearrange so the product is in the same form as Q_1 and Q_2 were above

\begin{array}{rcl}Q_1 Q_2 &=& w_1w_2 - x_1x_2 - y_1y_2 - z_1z_2 +{}\\&& (w_1x_2 + x_1w_2 + y_1z_2 - z_1y_2)\mathbf{i} +{}\\&& (w_1y_2 + z_1x_2 + y_1w_2 - x_1z_2)\mathbf{j} +{}\\&& (w_1z_2 + x_1y_2 + z_1w_2 - y_1x_2)\mathbf{k}\end{array}

which is the normal quaternion product that was given in its scalar + vector form earlier.

Remembering back to the first part of this post, the cross product is just the vector part of our quaternion multiplication if we take w = 0. So taking the w values as zero, the vector part of the last formula is

(y_1z_2 - z_1y_2)\mathbf{i} + (z_1x_2 - x_1z_2)\mathbf{j} + (x_1y_2 - y_1x_2)\mathbf{k}

which is the definition of the cross product as expected. So there you have it a derivation of the cross product that doesn’t treat it as a rabbit from a hat.

First post!

06-Mar-10

I’m putting this blog up to give me space to write about things I’m thinking about. In general that means stuff will be related to programming and/or games.

We’ll see how this goes.