Dot & Cross Products

2.Dot & Cross Product

Use the dot product to measure alignment. Use the cross product to find perpendicular directions.

§RRead

How parallel? How perpendicular?

The dot product of two vectors answers: "how much do they point in the same direction?" If both point the same way, the dot product is positive and large. If they are perpendicular, it is exactly zero. If they oppose, it is negative. Mathematically: u . v = |u| |v| cos(theta).

The cross product gives you a third vector perpendicular to both inputs. Its magnitude is |u| |v| sin(theta) — maximum when the vectors are perpendicular, zero when parallel. In graphics, cross products find surface normals: the direction a triangle faces.

§TTry

Rotate and watch the trace.

The cyan vector is fixed. Drag the green vector around the circle and watch the dot product trace a cosine curve on the graph.

fig. 2-1
Drag the green vector around the circle. The graph traces the dot product (cosine of the angle) in real time.
fig. 2-1 — dot-product-dial — rotating vector with live cos trace

Now toggle the cross product on. The gold trace is the sine of the angle — maximum at 90 degrees, zero at 0 and 180.

fig. 2-2
Drag the green vector around the circle. The graph traces the dot product (cosine of the angle) in real time. Gold trace = cross product magnitude (sine).
fig. 2-2 — dot-product-dial — with cross product magnitude visible
§PPredict

At what angle is the dot product zero?

§VVerify

Watch the zero-crossings.

Drag the green vector to exactly 90 degrees (pointing straight up). The dot product readout should show 0.000. Then try 270 degrees (pointing down) — also zero. These are the perpendicular orientations.

fig. 2-3
Drag the green vector around the circle. The graph traces the dot product (cosine of the angle) in real time. Gold trace = cross product magnitude (sine).
fig. 2-3 — dot-product-dial — confirm the zero-crossings
§MModify

Find a perpendicular vector.

Challenge: Given the vector (1, 2, 3), find any vector perpendicular to it. Hint: the dot product of perpendicular vectors is zero, so you need 1*a + 2*b + 3*c = 0. One solution: (0, 3, -2). Another: (2, -1, 0). There are infinitely many — any vector in the plane perpendicular to (1, 2, 3).

Show one solution

(0, 3, -2) — check: 1*0 + 2*3 + 3*(-2) = 0 + 6 - 6 = 0.

Checkpoint

Using the dial above, position the green vector so the dot product is as close to -1.000 as possible (vectors pointing in opposite directions). Then mark complete.

fig. 2-4
Drag the green vector around the circle. The graph traces the dot product (cosine of the angle) in real time.
fig. 2-4 — checkpoint — achieve dot = -1