Introduction to Graphics Math

Cross Product

A: (1.0, 1.0, 0.0)
B: (-2.0, 3.0, 0.0)
C: (0.0, 0.0, 5.0)

The cross product is a 3D vector operation so it's time to make the shift from 2D to 3D. In this demo you can rotate the camera to get a better perspective by holding shift and clicking and dragging or right clicking and dragging.

Here C is equal to A cross B. So whereas the dot product returns a scalar value, the cross product returns another vector. The extra element in these vectors is a z component, rather than a homogeneous coordinate weight.

C can be calculated with the following equations: \[ \textbf{C} = \textbf{A} \times \textbf{B} \] \[ = (A_yB_z-A_zB_y,\ A_zB_x-A_xB_z,\ A_xB_y-A_yB_x) \] \[ = ((1.0)(0.0)-(0.0)(2.0),\ (0.0)(-1.0)-(1.0)(0.0),\ (1.0)(2.0)-(1.0)(-1.0)) \] \[ = \underline{\underline{(0.0,0.0,3.0)}} \]

The cross product can be thought of as how perpendicular two vectors are. The resulting vector is perpendicular to both vectors in being crossed and its length is equal to the product of each vector's magnitude times the sine of the angle between them: \[ \|\textbf{C}\| = \|\textbf{A}\|\|\textbf{B}\|sin\ \theta \]

There are always two directions that can be perpendicular to the two crossed vectors. The standard way of choosing which direction the cross product calculates is by using the right hand rule. By curling the fingers on your right hand around from A to B, your thumb will be pointing in the direction of the cross product.

Things to try:

  • Drag A onto the same line as B. Notice how C is equal to (0,0,0).
  • Drag A more and more perpendicular to B. Notice how C gets longer and longer.
  • Drag A from one side of B to the other. Notice how the direction of C flips as you cross over. Line up your right hand with the vectors so you understand the right hand rule.