Cross Product

The 3D vector operation that produces a perpendicular vector.

7 min read Intermediate

Contents

Definition

The cross product (also called vector product) is an operation on two 3D vectors that produces a third vector perpendicular to both inputs.

Key difference from dot product: While the dot product returns a scalar, the cross product returns a vector.

The Formula

For vectors \(\vec{a} = (a_1, a_2, a_3)\) and \(\vec{b} = (b_1, b_2, b_3)\):

\[\vec{a} \times \vec{b} = \begin{pmatrix} a_2b_3 - a_3b_2 \\ a_3b_1 - a_1b_3 \\ a_1b_2 - a_2b_1 \end{pmatrix}\]

This can be remembered using the determinant of a 3×3 matrix:

\[\vec{a} \times \vec{b} = \begin{vmatrix} \hat{i} & \hat{j} & \hat{k} \\ a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3 \end{vmatrix}\]

Worked Example

Let's calculate \(\vec{a} \times \vec{b}\) where \(\vec{a} = (2, 3, 4)\) and \(\vec{b} = (5, 6, 7)\):

x-component: (3)(7) - (4)(6) = 21 - 24 = -3
y-component: (4)(5) - (2)(7) = 20 - 14 = 6
z-component: (2)(6) - (3)(5) = 12 - 15 = -3
Result: \(\vec{a} \times \vec{b} = (-3, 6, -3)\)

Geometric Interpretation

Direction: Right-Hand Rule

The cross product \(\vec{a} \times \vec{b}\) points in the direction given by the right-hand rule:

  1. Point your fingers in the direction of \(\vec{a}\)
  2. Curl them toward \(\vec{b}\)
  3. Your thumb points in the direction of \(\vec{a} \times \vec{b}\)
a b a × b

The cross product is perpendicular to both input vectors

Magnitude

The magnitude of the cross product equals the area of the parallelogram formed by the two vectors:

\[|\vec{a} \times \vec{b}| = |\vec{a}| \cdot |\vec{b}| \cdot \sin(\theta)\]

Properties

Property Formula
Anti-commutative \(\vec{a} \times \vec{b} = -(\vec{b} \times \vec{a})\)
Distributive \(\vec{a} \times (\vec{b} + \vec{c}) = \vec{a} \times \vec{b} + \vec{a} \times \vec{c}\)
Scalar multiplication \((c\vec{a}) \times \vec{b} = c(\vec{a} \times \vec{b})\)
Parallel vectors \(\vec{a} \times \vec{a} = \vec{0}\)
Not commutative! Unlike the dot product, order matters: \(\vec{a} \times \vec{b} \neq \vec{b} \times \vec{a}\). In fact, they point in opposite directions.

Applications

1. Surface Normals (Computer Graphics)

The cross product computes the normal vector to a surface, essential for lighting calculations:

// Given two edge vectors of a triangle
const edge1 = subtract(v2, v1);
const edge2 = subtract(v3, v1);
const normal = cross(edge1, edge2);
const unitNormal = normalize(normal);

2. Torque (Physics)

Torque is the cross product of the position vector and force:

\[\vec{\tau} = \vec{r} \times \vec{F}\]

3. Angular Momentum

\[\vec{L} = \vec{r} \times \vec{p}\]

4. Area Calculation

The area of a parallelogram with sides \(\vec{a}\) and \(\vec{b}\):

\[\text{Area} = |\vec{a} \times \vec{b}|\]

Triangle area is half this value.

Code Examples

JavaScript

function crossProduct(a, b) {
    return [
        a[1] * b[2] - a[2] * b[1],
        a[2] * b[0] - a[0] * b[2],
        a[0] * b[1] - a[1] * b[0]
    ];
}

const a = [2, 3, 4];
const b = [5, 6, 7];
console.log(crossProduct(a, b)); // [-3, 6, -3]

Python

import numpy as np

a = np.array([2, 3, 4])
b = np.array([5, 6, 7])
result = np.cross(a, b)  # array([-3, 6, -3])

Cross Product vs Dot Product

Aspect Dot Product Cross Product
Returns Scalar Vector
Works in Any dimension 3D only*
Commutative Yes No (anti-commutative)
Zero when Perpendicular Parallel
Uses \(\cos\) or \(\sin\) \(\cos(\theta)\) \(\sin(\theta)\)

*The cross product can be generalized to 7D, but the 3D version is by far the most common.

Next Steps

💡

The Cross Product Explained Simply

Imagine you have two arrows lying flat on a table. The cross product creates a brand new arrow that shoots straight up from the table, perfectly perpendicular to both of your original arrows. This is what makes the cross product special - it always produces a result that points in a completely different direction from the inputs. Think of it like two roads crossing at an intersection; the cross product points straight up into the sky, at right angles to both roads.

To figure out which way the new arrow points (up or down), we use the right-hand rule. Here is a simple way to remember it: make a thumbs-up gesture with your right hand. Point your fingers in the direction of the first vector, then curl them toward the second vector. Your thumb now points in the direction of the cross product. Try it yourself - if you reverse the order of the vectors, your thumb points the opposite way. This is why order matters in cross products!

The cross product also tells us something about area. The length of the resulting vector equals the area of the parallelogram you could draw using your two original vectors as sides. If the vectors are parallel (pointing the same direction), they cannot form a parallelogram with any area, which is why the cross product of parallel vectors is zero. The more perpendicular your vectors are, the larger the cross product becomes.

In the real world, cross products pop up everywhere. When you turn a wrench, the torque is a cross product between the wrench handle and the force you apply. When light bounces off a surface, the cross product helps calculate which direction is "outward" from that surface. Game engines use cross products millions of times per second to figure out lighting, collisions, and camera angles. Once you understand this perpendicular-arrow concept, you will start seeing it everywhere!

Frequently Asked Questions

What is the cross product?

The cross product is a mathematical operation that takes two 3D vectors and produces a third vector that is perpendicular to both of them. Unlike the dot product which returns a single number, the cross product returns a new vector. It is also called the vector product and is denoted by the symbol x (multiplication sign) between two vectors.

When is the cross product zero?

The cross product is zero when the two vectors are parallel or anti-parallel (pointing in the same or opposite directions). This happens because parallel vectors cannot define a unique perpendicular direction, and the area of the parallelogram they would form is zero. Mathematically, when the angle between vectors is 0 or 180 degrees, sin(theta) equals zero, making the cross product zero.

What is the difference between dot product and cross product?

The dot product returns a scalar (a single number) and measures how much two vectors point in the same direction, using cosine. The cross product returns a vector perpendicular to both inputs and uses sine. The dot product is zero when vectors are perpendicular, while the cross product is zero when vectors are parallel. The dot product works in any dimension, but the cross product only works in 3D (and 7D).

Why does the cross product only work in 3D?

The cross product requires exactly 3 dimensions because it produces a vector perpendicular to both inputs, and this unique perpendicular direction only exists in 3D space. In 2D, there is no third dimension for the result to point into. In higher dimensions like 4D, there are infinitely many perpendicular directions, making the result ambiguous. Mathematically, the cross product is related to the 3D rotation group and requires exactly 3 components.

How do you calculate the cross product?

To calculate the cross product of vectors a = (a1, a2, a3) and b = (b1, b2, b3), compute each component separately: x = a2*b3 - a3*b2, y = a3*b1 - a1*b3, z = a1*b2 - a2*b1. A helpful memory trick is to use the determinant of a 3x3 matrix with unit vectors i, j, k in the first row, vector a in the second row, and vector b in the third row.

What is the right-hand rule for cross products?

The right-hand rule is a technique to determine the direction of a cross product. Point your right hand fingers in the direction of the first vector, then curl them toward the second vector. Your thumb will point in the direction of the cross product result. If you swap the order of the vectors, the result points in the opposite direction, which is why the cross product is anti-commutative.

Is the cross product commutative?

No, the cross product is anti-commutative, which means a x b = -(b x a). Swapping the order of the vectors reverses the direction of the result. This is different from the dot product, which is commutative (a . b = b . a). The anti-commutative property is important in physics when calculating torque or angular momentum, where direction matters.

What are the real-world applications of cross products?

Cross products are used extensively in physics, engineering, and computer graphics. Common applications include calculating torque (force times lever arm), finding surface normals for 3D lighting and rendering, computing angular momentum, determining magnetic force on moving charges, calculating the area of triangles in 3D space, and detecting which side of a plane a point lies on.

How do you find the magnitude of a cross product?

The magnitude of the cross product equals |a| * |b| * sin(theta), where |a| and |b| are the magnitudes of the input vectors and theta is the angle between them. This magnitude represents the area of the parallelogram formed by the two vectors. For a triangle with two sides as vectors, the area is half the magnitude of their cross product.

Can you do a cross product in 2D?

The true cross product does not exist in 2D, but there is a useful 2D analog. For 2D vectors a = (a1, a2) and b = (b1, b2), you can compute a1*b2 - a2*b1, which gives a scalar representing the signed area of the parallelogram. This is equivalent to treating the 2D vectors as 3D vectors with z=0 and taking only the z-component of the cross product. This 2D cross product is useful for determining if a point is to the left or right of a line.