This is Words and Buttons Online — a collection of interactive #tutorials, #demos, and #quizzes about #mathematics, #algorithms and #programming.

Interactive mnemonics for dot and cross vector products

Dot and cross vector products are absolutely essential for everything three-dimensional. Whatever 3D thing you do: graphics, printing, physical simulation, — as soon as you want anything beyond what your framework provides, you have to do some vector magic, and these are your most basic spells.

The more embarrassing it is for me to admit. Up until very recently, I couldn't remember which way a cross product goes.

Sure, we all studied this in college. It wasn't too hard either. But without practice, the knowledge deteriorates to the bare minimum. And even with practice, some things are just getting lost in memory. Not that it's a huge issue. But remembering basic things saves time on needless experiments, plus, as I just mentioned, it's embarrassing not to remember them.

So I came up with a pair of problems, taken from practice, that do not only show properties of dot and cross vector products but are also mnemonically connected to the names “dot” and “cross”.

Dot product and point light

Point lighting is a technique used in 3D graphics. Let's pretend, all our light comes from one point in space. Then the amount of light reflected from some point of a surface will be determined by:

  1. The distance to the light source.
  2. The cosine of the angle between the surface normal and the direction to the light source.

The first thing is called attenuation and it has nothing to do with the vector products. The second, however, is exactly the dot product.

Here is an interactive model of point light source. You can move the source and also pick a point on the surface to compute the dot product in.

Having this model installed in your brain, it's easy to remember that the dot product is maximal for codirectional vectors, minimal for contradirectional, and is zero for the orthogonal vectors. The specific order of vectors doesn't matter.

Cross product and crossing the road

Cross product is a bit more difficult to explain since it makes little sense in two-dimensional space, and all the textbooks and blackboards and displays are two-dimensional.

In 3D it is a product of two vectors resulting in a third vector. The resulting vector is orthogonal to both input vectors. Its length equals the area of the parallelogram formed by the inputs. When the vectors are normalized, their cross product also equals the sine of the angle between them. The first, the second, and the resulting vectors form a right-hand triplet. This means that swapping input vectors also inverts the product.

These are all googleable facts, but to keep them inside the head and not in the Google, we need a good practical example and we better have this example on a flat display, too.

Lucky for us, there is one particular two-dimensional application where cross product is used and it is the half-plane classification.

Let's say we divide a 2D plane with a line. Let the line be given by a pair of points. For every point on a plane, we want to know if the point is on one side of the dividing line or the other?

If we add a new dimension to the plane, we can use the cross product to detect when the point is crossing the line. Let's form a pair of vectors. One between the points of the dividing line, and the other — from the first point of that line to the point we want to classify.

Since the input vectors lie on a plane z = 0, and the cross product is orthogonal to both, the cross product of the input vectors will always be a vector with two zeros: (0, 0, z). Now if a point to classify results to a positive z in their cross product, it lies on the left of the dividing line. If it's negative, then it's on the right. If it's zero, then we caught our point exactly crossing the line. It's neither on the right nor on the left.

Here's an interactive mnemonic. You can move the stick-man.

ijk
x1y10.00
x2y20.00

P. S.

I have these mnemonics planted in my head but there are probably even better ones out there. If you know a good example, please let me know.