The Cross Product
The cross product takes two vectors in and returns a third vector perpendicular to both. Its length is the area of the parallelogram they span, and its direction follows the right-hand rule. This lesson defines it with determinants, proves its geometric properties, and builds the scalar triple product, which gives volumes and tests for coplanarity.
For a gentler first pass, see Dot and Cross Products.
Definition via determinants
A determinant is . For and ,
The "determinant" with in its first row is a memory aid: expand along that row. The cross product exists only in (and, in a weaker form, ). In 2D, the scalar plays its role.
Geometric properties
Theorem 1. is orthogonal to both and .
Proof. Expand: . The six terms cancel in pairs, so the sum is 0. The same calculation works for . ∎
Theorem 2. , where is the angle between and .
Proof. Expanding both sides gives Lagrange's identity:
Substitute : . Take the square root, using on . ∎
Corollaries.
- is the area of the parallelogram spanned by and (base , height ). Half of it is the area of the triangle.
- Nonzero vectors and are parallel if and only if .
The direction is fixed by the right-hand rule: curl your fingers from to through , and your thumb points along . For the basis vectors, , and .
Algebraic rules (and non-rules)
| Rule |
Note |
|
anti-commutative: order matters |
|
|
|
distributive |
|
|
| in general |
not associative: but |
|
the "BAC − CAB" rule |
python · try it yourselfimport numpy as np
a, b = np.array([2.0, -1.0, 3.0]), np.array([1.0, 4.0, 0.0])
c = np.cross(a, b)
print("a x b =", c, " b x a =", np.cross(b, a))
print("orthogonal:", c @ a, c @ b)
lhs = np.linalg.norm(c) ** 2
rhs = (a @ a) * (b @ b) - (a @ b) ** 2
print("|a x b|^2 =", round(float(lhs), 10), " Lagrange:", float(rhs))
print("triangle area =", round(float(np.linalg.norm(c)) / 2, 4))
i, j = np.array([1, 0, 0]), np.array([0, 1, 0])
print("(i x i) x j =", np.cross(np.cross(i, i), j), " i x (i x j) =", np.cross(i, np.cross(i, j)))
a x b = [-12. 3. 9.] b x a = [12. -3. -9.]
orthogonal: 0.0 0.0
|a x b|^2 = 234.0 Lagrange: 234.0
triangle area = 7.6485
(i x i) x j = [0 0 0] i x (i x j) = [ 0 -1 0]
The scalar triple product
Theorem 3. is the volume of the parallelepiped with edges , and .
Proof. The base is the parallelogram on and , with area . The height is the length of the projection of onto the base normal , which is , where is the angle between and . So the volume is . ∎
So three vectors are coplanar exactly when . The sign gives the orientation: positive when form a right-handed system. The triple product is cyclic, , because cyclically permuting the rows of a determinant does not change it.
Torque. A force applied at position relative to a pivot produces torque , with . Only the perpendicular part of the force turns the wrench.
python · try it yourselfimport numpy as np
a, b, c = np.array([1.0, 2.0, 0.0]), np.array([0.0, 1.0, 3.0]), np.array([2.0, 0.0, 1.0])
vol = a @ np.cross(b, c)
print("a·(b×c) =", vol, " det =", round(float(np.linalg.det(np.array([a, b, c]))), 10))
print("cyclic b·(c×a) =", b @ np.cross(c, a))
d = 2 * a - 3 * b # lies in the plane of a and b
print("coplanar a, b, 2a-3b:", a @ np.cross(b, d))
r, F = np.array([0.3, 0.0, 0.0]), np.array([0.0, 40.0, -10.0]) # m, N
print("torque r x F =", np.cross(r, F) + 0.0, " |τ| =", round(float(np.linalg.norm(np.cross(r, F))), 4), "N·m")
a·(b×c) = 13.0 det = 13.0
cyclic b·(c×a) = 13.0
coplanar a, b, 2a-3b: 0.0
torque r x F = [ 0. 3. 12.] |τ| = 12.3693 N·m
In software
- Surface normals and winding. A triangle with vertices has normal . Swapping two vertices flips . GPUs use this winding order (counter-clockwise = front by default in OpenGL) to cull back faces, so a mesh exported with the wrong winding renders inside-out (Cross Product in games).
- Handedness. The formula is the same in left- and right-handed engines, but the picture flips: in a left-handed system points the "other" way under the right-hand rule. That is why the same code can produce mirrored cameras after an engine port (Handedness).
- Orientation tests. The 2D cross product sign answers "is point left of line ?", the core of convex hulls, polygon triangulation and segment intersection. In 3D, the triple-product sign tells which side of a plane a point lies on.
- Physics. Angular velocity, torque and the velocity of a point on a spinning body () are all cross products (Rotation Dynamics).
Exercises
Exercise 1: Compute and check
Compute and verify that the result is orthogonal to both vectors.
Answer
Solution
Exercise 2: Triangle area
Find the area of the triangle with vertices , , .
Answer
Solution
Exercise 3: Are four points coplanar?
Are , , and in one plane?
Answer
Yes: .
Solution
Indeed .
Exercise 4: Fix the winding (code)
A mesh triangle has vertices , , , and the outward normal should point toward . Compute its normal, detect that the winding is wrong, and fix it by swapping two vertices.
Answer
The normal is (wrong side). After swapping the last two vertices it is .
Solution
python · try it yourselfimport numpy as np
tri = [np.array(v, float) for v in [(0, 0, 0), (0, 1, 0), (1, 0, 0)]]
normal = lambda t: np.cross(t[1] - t[0], t[2] - t[0])
print("normal:", normal(tri))
if normal(tri) @ np.array([0, 0, 1]) < 0:
tri[1], tri[2] = tri[2], tri[1]
print("fixed :", normal(tri))
normal: [ 0. 0. -1.]
fixed : [0. 0. 1.]
Test yourself
What is ?
equals…
- the area of the parallelogram spanned by and
- the volume spanned by and
tells you that…
- all have length 0
- is parallel to
- are coplanar