Definition
The cross product (also called vector product) is an operation on two 3D vectors that produces a third vector perpendicular to both inputs.
The Formula
For vectors \(\vec{a} = (a_1, a_2, a_3)\) and \(\vec{b} = (b_1, b_2, b_3)\):
This can be remembered using the determinant of a 3×3 matrix:
Worked Example
Let's calculate \(\vec{a} \times \vec{b}\) where \(\vec{a} = (2, 3, 4)\) and \(\vec{b} = (5, 6, 7)\):
Geometric Interpretation
Direction: Right-Hand Rule
The cross product \(\vec{a} \times \vec{b}\) points in the direction given by the right-hand rule:
- Point your fingers in the direction of \(\vec{a}\)
- Curl them toward \(\vec{b}\)
- Your thumb points in the direction of \(\vec{a} \times \vec{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:
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}\) |
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:
3. Angular Momentum
4. Area Calculation
The area of a parallelogram with sides \(\vec{a}\) and \(\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
- Vector Projection - Project vectors using dot products
- Cross Product Calculator - Interactive tool
- SVG & Graphics - See cross products in action