explainer
Cross product: find a normal direction and calculate torque
Calculate a three-dimensional cross product, follow the right-hand rule, and connect its magnitude to area. Explore signed torque with a movable lever arm and force.
What you will learn
- Calculate a cross product and check its direction and orthogonality.
- Explain its magnitude using a parallelogram and identify zero results.
- Compute a force's torque about a stated pivot with correct units.
Before you start
The cross product takes two three-dimensional vectors and returns a vector perpendicular to both. Its direction records their order. Its magnitude measures how much area they span.
That same calculation gives the torque of a force about a pivot. This lesson connects the coordinate formula to a synthetic robot arm example, with numbers you can check by hand.
Work in one three-dimensional frame
Use real vectors a = (aₓ, aᵧ, a_z) and b = (bₓ, bᵧ, b_z). The formula below assumes a right-handed orthonormal frame: three mutually perpendicular unit axes, with positive x crossed into positive y giving positive z.
Both vectors must use that same frame. For example, first express a tool's force in the robot base frame if the lever arm uses base-frame coordinates. The vector-space lesson explains how coordinates describe vectors relative to a basis.
The result a × b has three components. When it is nonzero, it supplies a normal direction to the plane containing the inputs. The dot product supplies a scalar that you can use to check this perpendicularity.
This lesson uses the usual cross product in three-dimensional Euclidean space. An arbitrary list of many machine learning features needs an operation defined for that feature space.
Calculate the three components
Write c = a × b. Compute each component from two products:
cₓ = aᵧb_z − a_zbᵧ
cᵧ = a_zbₓ − aₓb_z
c_z = aₓbᵧ − aᵧbₓ
The middle component's sign is a common source of errors. Keeping this component form beside your code makes that sign easy to inspect. MIT's cross-product notes connect the algebraic and geometric definitions.
For a = (1, 2, 3) and b = (4, −1, 2):
- x component: 2 × 2 − 3 × (−1) = 7.
- y component: 3 × 4 − 1 × 2 = 10.
- z component: 1 × (−1) − 2 × 4 = −9.
So a × b = (7, 10, −9). Check the two dot products:
- a · c = 1 × 7 + 2 × 10 + 3 × (−9) = 0.
- b · c = 4 × 7 + (−1) × 10 + 2 × (−9) = 0.
These checks confirm that c is orthogonal to each input. They also help catch a copied component or sign error.
Follow the right-hand rule
Point your right-hand fingers along the first vector. Curl them toward the second through the angle from 0° to 180°. For nonparallel inputs, your thumb gives the cross-product direction.
With x pointing right and y pointing up on this page, x × y points out of the page. The symbol ⊙ shows the tip of an arrow coming toward you. ⊗ shows the tail of an arrow pointing away.
Swapping the inputs reverses a nonzero result:
b × a = −(a × b)
This property is called anticommutativity. Our worked example therefore gives b × a = (−7, −10, 9). OpenStax explains the right-hand rule and cross-product properties.
The operation also distributes over addition: a × (b + c) = a × b + a × c. Multiplying one input by a scalar multiplies the output by that scalar. Keep parentheses in nested cross products; changing their grouping can change the answer.
Read magnitude as an area
For nonzero inputs, let θ be the angle between them. Their cross-product magnitude is:
‖a × b‖ = ‖a‖ ‖b‖ sin θ
Draw the vectors as adjacent sides of a parallelogram. Its base has length ‖a‖, and its perpendicular height is ‖b‖ sin θ. Multiplying base by height gives the formula.
For a separate geometric example, take a = (3, 0, 0) m and b = (2, 4, 0) m. The cross product is (0, 0, 12) m². The parallelogram has base 3 m and height 4 m, so its area is 12 m²; its triangle half has area 6 m². The determinant lesson uses the corresponding two-dimensional calculation to measure signed area scaling by a matrix.
Here both inputs describe lengths. In other applications, the output carries the product of the input units. The vector-norms lesson explains the Euclidean magnitude used by this formula.
Recognize a zero cross product
Parallel and opposed nonzero vectors have zero cross product. Their angle is 0° or 180°, and their parallelogram has zero height. Crossing any vector with the zero vector also gives (0, 0, 0).
The zero result has no direction. You cannot divide it by its magnitude to make a unit normal. For a nonzero cross product, that division gives a unit normal, with its sign determined by input order.
For example, (1, 1, 0) × (2, 2, 0) = (0, 0, 0). Both inputs have length, but they provide only one independent direction. A measured pair that is nearly parallel can produce a small, noise-sensitive normal, so inspect the magnitude before normalizing.
Calculate torque about a pivot
Let r point from the pivot to the force application point. Let F be the applied force, expressed in the same frame. That force's torque about the pivot is τ = r × F. OpenStax derives torque from the force and moment arm.
Suppose a robot link's application point lies at r = (2, 0, 0) m, and the force is F = (0, 3, 0) N. Since both inputs have zero z component, only the torque's z component remains:
τ_z = rₓFᵧ − rᵧFₓ
τ_z = 2 × 3 − 0 × 0 = 6 N·m
The full result is τ = (0, 0, 6) N·m. It points out of the page and describes a counterclockwise turning tendency in this view. It does not, by itself, establish how the link moves; other forces, constraints, and the body's inertia also matter.
The torque magnitude also equals force magnitude × perpendicular distance from the pivot to the force's line of action. For a force directed along r, its line of action passes through the pivot, giving zero torque about that pivot. Changing the pivot can change the torque.
For an arm with several joints, repeat the moment calculation about each joint. The robot statics lesson connects those moments to the Jacobian transpose and calculates the actuator torques that balance an applied tool load.
Use newton metres (N·m) for torque. Torque and energy share base-unit dimensions, but they describe different quantities; the SI names energy's unit the joule. NIST specifies this distinction.
Change the lever arm and force
The explorer starts with the 6 N·m example. Its planar inputs illustrate a three-dimensional output. The signed scalar τ_z records the z component; the full vector readout keeps the other two components visible.
Try three changes and predict the result first:
- Choose Negative torque. Reversing the force to (0, −3, 0) N gives τ_z = −6 N·m.
- Choose Parallel vectors. The two component products cancel: 1 × 2 − 1 × 2 = 0.
- Choose Force at pivot. Setting r to zero makes every component product zero, even with a nonzero force.
Each grid interval uses separate arrow scales: 2 m for r and 2 N for F. The shaded parallelogram explains the angular dependence using these scaled arrows. Its screen area is a drawing; the torque readout has units N·m.
For an oblique example, set r = (2, 1, 0) m and F = (1, 3, 0) N. You should get τ_z = 2 × 3 − 1 × 1 = 5 N·m. Moving the application point and changing the force can each alter the result.
Connect rotation to point velocity
The rotation matrices lesson describes a finite change in direction. Angular velocity describes how orientation changes with time.
For a finite turn about an arbitrary axis, Rodrigues' rotation formula uses a cross product to supply the direction of the sine term. The axis-parallel component stays fixed while the perpendicular component turns.
For a rigid body rotating about a fixed origin, a point's velocity is v = ω × r. Here ω is angular velocity in radians per second, and r runs from that origin to the point. OpenStax gives this relation for rotational motion.
Take ω = (0, 0, 2) rad/s and r = (2, 0, 0) m. The cross product gives v = (0, 4, 0) m/s, tangent to the point's circular path. Radians are dimensionless in SI, which leaves velocity units of metres per second.
If a reference point O on the rigid body also translates, include its velocity: v_P = v_O + ω × r_OP. The cross product supplies the rotational contribution. This relation assumes P stays fixed in the rigid body; a sliding point needs its additional relative motion accounted for.
The University of Illinois rigid-body notes explain the reference-point relation.
With a fixed first vector, you can also write the cross product as a matrix acting on the second vector:
[ 0 -az ay ]
a × b = [ az 0 -ax ] b
[-ay ax 0 ]
The matrix-multiplication lesson shows how each row produces an output component. Expanding those three rows recovers the coordinate formula above.
Run the calculation in Python
This example uses Python's standard library. The cross-product function accepts three-component tuples, so the same code covers the full 3D example and the planar torque example.
from math import sqrt
def cross(a, b):
ax, ay, az = a
bx, by, bz = b
return (ay * bz - az * by,
az * bx - ax * bz,
ax * by - ay * bx)
def dot(a, b):
return sum(x * y for x, y in zip(a, b))
a = (1, 2, 3)
b = (4, -1, 2)
c = cross(a, b)
print("a x b:", c)
print("Orthogonality checks:", dot(a, c), dot(b, c))
print("Cross magnitude:", round(sqrt(dot(c, c)), 3))
r = (2, 0, 0) # metres, from pivot to application point
force = (0, 3, 0) # newtons, in the same frame
print("Torque (N m):", cross(r, force))
print("Reversed force torque:", cross(r, (0, -3, 0)))
print("Parallel inputs:", cross((1, 1, 0), (2, 2, 0)))
print("Point velocity (m/s):", cross((0, 0, 2), r))
Expected output:
a x b: (7, 10, -9)
Orthogonality checks: 0 0
Cross magnitude: 15.166
Torque (N m): (0, 0, 6)
Reversed force torque: (0, 0, -6)
Parallel inputs: (0, 0, 0)
Point velocity (m/s): (0, 4, 0)
The integer examples give exact zero checks. With measured floating-point inputs, use a tolerance scaled to the vectors when checking numerical orthogonality.
Try it yourself
Exercise 1. A force F = (4, 0, 0) N acts at r = (0, 1.5, 0) m relative to a pivot. Find the full torque vector, its magnitude, and its direction in the page view. What changes if you double the force?
Show solution
The z component is 0 × 0 − 1.5 × 4 = −6 N·m, so τ = (0, 0, −6) N·m. Its magnitude is 6 N·m, and it points into the page. Doubling F gives (0, 0, −12) N·m with the same direction.
Exercise 2. Two geometric vectors are a = (2, 0, 0) m and b = (1, 3, 0) m. Find their parallelogram area and a unit normal. Then replace b with (−4, 0, 0) m and explain whether a unit normal still follows from their cross product.
Show solution
The first cross product is (0, 0, 6) m². Its magnitude gives area 6 m²; dividing by that magnitude gives the dimensionless unit normal (0, 0, 1).
The replacement b points opposite a, so their cross product is zero. The parallelogram has zero area. Dividing by zero cannot produce a unit normal; this pair supplies no unique plane normal.
Sources and further study
- MIT World Web Math: Cross Product, coordinate calculation and geometry.
- OpenStax Calculus Volume 3: The Cross Product, right-hand rule, identities, and area.
- OpenStax University Physics Volume 1: Torque, force, pivot, and perpendicular moment arm.
- OpenStax University Physics Volume 1: Rotational Variables, angular velocity and point velocity.
- University of Illinois Mechanics Reference: Rigid Bodies, translation and rotation relative to a point on the body.
- NIST SP 330: The International System of Units, units of torque, energy, and angular measure.