Skip to content

Cross Product and Vector Projections

In this lesson you’ll learn the cross product (a key 3D operation) and vector projection, which tells you how much of one vector lies in the direction of another.

The cross product u×v\mathbf{u} \times \mathbf{v} of two vectors in 3D produces a new vector that is perpendicular to both u\mathbf{u} and v\mathbf{v}.

Formula (using the determinant):

u×v=u2v3u3v2,  u3v1u1v3,  u1v2u2v1\mathbf{u} \times \mathbf{v} = \langle u_2 v_3 - u_3 v_2,\; u_3 v_1 - u_1 v_3,\; u_1 v_2 - u_2 v_1 \rangle

Key properties:

  • The result is perpendicular to both input vectors (right-hand rule)
  • Magnitude: u×v=uvsinθ\lVert \mathbf{u} \times \mathbf{v} \rVert = \lVert \mathbf{u} \rVert \lVert \mathbf{v} \rVert \sin \theta (equals the area of the parallelogram formed by u\mathbf{u} and v\mathbf{v})
  • Anti-commutative: u×v=(v×u)\mathbf{u} \times \mathbf{v} = -(\mathbf{v} \times \mathbf{u})

The projection of vector u\mathbf{u} onto vector v\mathbf{v} tells you “how much of u\mathbf{u} points in the direction of v\mathbf{v}.”

projvu=(uvv2)v\text{proj}_{\mathbf{v}} \mathbf{u} = \left( \frac{\mathbf{u} \cdot \mathbf{v}}{\lVert \mathbf{v} \rVert^2} \right) \mathbf{v}

Think of it as the “shadow” of u\mathbf{u} cast onto v\mathbf{v}. The dashed line drops straight down (perpendicular) from the tip of u\mathbf{u} to the line of v\mathbf{v}:

u v proj drop u = ⟨3, 4⟩ proj = ⟨3, 0⟩ perpendicular drop

In the diagram: u=3,4\mathbf{u} = \langle 3, 4 \rangle (blue) is projected onto the x-axis direction v=5,0\mathbf{v} = \langle 5, 0 \rangle. The orange arrow is the projection projvu=3,0\text{proj}_{\mathbf{v}} \mathbf{u} = \langle 3, 0 \rangle. The dashed purple line shows the perpendicular drop from the tip of u\mathbf{u} down to the projection. The y-component is stripped away, leaving only the part of u\mathbf{u} that lies along v\mathbf{v}.

Example 1: Cross Product

u=1,2,3\mathbf{u} = \langle 1, 2, 3 \rangle, v=4,5,6\mathbf{v} = \langle 4, 5, 6 \rangle

u×v=(2)(6)(3)(5),  (3)(4)(1)(6),  (1)(5)(2)(4)=3,6,3\mathbf{u} \times \mathbf{v} = \langle (2)(6) - (3)(5),\; (3)(4) - (1)(6),\; (1)(5) - (2)(4) \rangle = \langle -3, 6, -3 \rangle

Step by step:

  • First component: 2×63×5=1215=32 \times 6 - 3 \times 5 = 12 - 15 = -3
  • Second component: 3×41×6=126=63 \times 4 - 1 \times 6 = 12 - 6 = 6
  • Third component: 1×52×4=58=31 \times 5 - 2 \times 4 = 5 - 8 = -3

In the 3D scene above: u=1,2,3\mathbf{u} = \langle 1, 2, 3 \rangle (blue) and v=4,5,6\mathbf{v} = \langle 4, 5, 6 \rangle (green) lie in a plane shown by the shaded purple parallelogram. The cross product u×v=3,6,3\mathbf{u} \times \mathbf{v} = \langle -3, 6, -3 \rangle (orange) sticks straight out of that plane, perpendicular to both input vectors. Drag to rotate and see how the orange arrow is always at a right angle to the purple surface.

Example 2: Magnitude of Cross Product

Using the same vectors:

u×v=(3)2+62+(3)2=9+36+9=54=36\lVert \mathbf{u} \times \mathbf{v} \rVert = \sqrt{(-3)^2 + 6^2 + (-3)^2} = \sqrt{9 + 36 + 9} = \sqrt{54} = 3\sqrt{6}

This equals uvsinθ\lVert \mathbf{u} \rVert \lVert \mathbf{v} \rVert \sin \theta and represents the area of the parallelogram formed by u\mathbf{u} and v\mathbf{v}.

Example 3: Vector Projection

Project u=3,4\mathbf{u} = \langle 3, 4 \rangle onto v=5,0\mathbf{v} = \langle 5, 0 \rangle (along the x-axis).

Step 1: uv=(3)(5)+(4)(0)=15\mathbf{u} \cdot \mathbf{v} = (3)(5) + (4)(0) = 15

Step 2: v2=52+02=25\lVert \mathbf{v} \rVert^2 = 5^2 + 0^2 = 25

Step 3: projvu=15255,0=355,0=3,0\text{proj}_{\mathbf{v}} \mathbf{u} = \frac{15}{25} \langle 5, 0 \rangle = \frac{3}{5} \langle 5, 0 \rangle = \langle 3, 0 \rangle

The y-component is removed. The projection lies entirely on the x-axis.

  • Cross Product: Used to calculate surface normals (for lighting), torque in physics, and angular momentum
  • Projection is used in games for:
    • Finding how much force applies in a certain direction
    • Calculating the closest point on a line or plane
    • Implementing “sliding” collision response
    • AI sight cones and threat detection

Example: When a character runs into a wall at an angle, projection helps calculate the sliding direction along the wall instead of stopping completely.

The cross product $\mathbf{u} \times \mathbf{v}$ produces a vector that is:
The magnitude $\lVert \mathbf{u} \times \mathbf{v} \rVert$ equals:
Vector projection of $\mathbf{u}$ onto $\mathbf{v}$ tells you:
If $\mathbf{u}$ and $\mathbf{v}$ are parallel, their cross product is:
In game development, projection is commonly used for: