What Is the Cross Product of 2D Vectors?
The cross product of 2d vectors is a fundamental operation in vector algebra. Unlike the 3D cross product that gives a vector, this operation returns a scalar – the signed area of the parallelogram the two vectors form. It is sometimes called the perp dot product or 2D cross product. Its compactness makes it ideal for physics simulations, computer graphics, and geometry. Every student of linear algebra encounters the cross product of 2d vectors early on because it is the simplest form of the cross product.
🔑 Key Takeaways
- The cross product of 2d vectors is a scalar, not a vector.
- It equals the signed area of the parallelogram spanned by the two vectors.
- Use it to test whether two vectors are parallel or to determine the winding order of points.
- The formula $a_x b_y – a_y b_x$ is easy to compute and remember.
- It is the 2D analogue of the 3D cross product’s magnitude.
Formula and Geometry
For any two 2D vectors $\mathbf{a}=(a_x,a_y)$ and $\mathbf{b}=(b_x,b_y)$, the cross product of 2d vectors is defined as:
For a deeper exploration of how this connects to the 3D version, see the Wikipedia article on cross product. For a more in‑depth derivation of the geometric interpretation, check out MathWorld’s cross product page.
Geometrically, this scalar equals $|\mathbf{a}|\,|\mathbf{b}|\,\sin\theta$, where $\theta$ is the signed angle from $\mathbf{a}$ to $\mathbf{b}$. Because $\sin\theta$ changes sign with orientation, the result tells you whether $\mathbf{b}$ lies to the left (positive) or right (negative) of $\mathbf{a}$. In practice, this property is why the operation appears in every collision detection system – it instantly reveals which side of a line a point lies on. The cross product of 2d vectors is thus a cornerstone of computational geometry.
Step-by-Step Calculation
Let’s compute the scalar cross product together. We’ll use $\mathbf{a} = (3, 1)$ and $\mathbf{b} = (2, 4)$.
- Identify components: $a_x=3$, $a_y=1$, $b_x=2$, $b_y=4$.
- Multiply crosswise: $a_x \cdot b_y = 3 \cdot 4 = 12$.
- Multiply the other way: $a_y \cdot b_x = 1 \cdot 2 = 2$.
- Subtract: $12 – 2 = 10$.
🧪 Worked example
$\mathbf{a}\times\mathbf{b} = 3\cdot4 – 1\cdot2 = 12 – 2 = 10$ (positive → $\mathbf{b}$ is counter‑clockwise from $\mathbf{a}$).
Now try $\mathbf{c} = (5, -2)$ and $\mathbf{d} = (1, 3)$:
🧪 Another example
$\mathbf{c}\times\mathbf{d} = 5\cdot3 – (-2)\cdot1 = 15 + 2 = 17$.
These examples show the cross product of 2d vectors in action. Note that the result is a single number – a scalar – not a vector. When components include negatives, be especially careful with the subtraction: $a_x b_y – a_y b_x$ always requires subtracting the product of the second pair, even if that product is negative. For example, with $\mathbf{e}=(-2, 3)$ and $\mathbf{f}=(4, -1)$, the cross product of 2d vectors is $(-2)(-1) – (3)(4) = 2 – 12 = -10$.
What about parallel vectors? Let $\mathbf{g}=(4, 6)$ and $\mathbf{h}=(2, 3)$. Then $4\cdot3 – 6\cdot2 = 12 – 12 = 0$. This zero result tells us the vectors are colinear – no area is spanned. This property is essential for checking collinearity in computational geometry.
Geometric Significance of the Cross Product of 2D Vectors
The absolute value of the scalar cross product gives the area of the parallelogram they span. For example, with $\mathbf{a}=(3,1)$ and $\mathbf{b}=(2,4)$, the area is $|10| = 10$ square units. Halving that gives the triangle area: $5$ units². This geometric meaning is why the cross product of 2d vectors appears in the shoelace formula for polygon area.
“The cross product of 2d vectors is the quickest path from coordinates to area – a single subtraction does what a whole trigonometry table used to.”
Computing the Angle Between Vectors
Because the magnitude of the 2D cross product equals $|\mathbf{a}||\mathbf{b}||\sin\theta|$, you can combine it with the dot product to find the full signed angle: $\tan\theta = \frac{\mathbf{a}\times\mathbf{b}}{\mathbf{a}\cdot\mathbf{b}}$ (using the cross product of 2d vectors in the numerator and dot product in the denominator). This formula is particularly useful in robotics for calculating the angle from one vector to another, avoiding ambiguity when using arccos alone.
Zero Cross Product
If the scalar cross product is zero, the vectors are parallel (or one is zero). For instance, $\mathbf{a}=(2,4)$ and $\mathbf{b}=(1,2)$ give $2\cdot2 – 4\cdot1 = 0$. They are colinear – no area is spanned. This property is essential for checking collinearity in computational geometry. Moreover, a zero cross product of 2d vectors also implies that the two vectors are linearly dependent.
Sign and Orientation
The sign of the scalar result indicates orientation. For two vectors $\mathbf{a}$ and $\mathbf{b}$, a positive result means $\mathbf{b}$ is counter‑clockwise from $\mathbf{a}$. Negative means clockwise. This is used in determining the winding order of polygons – if you sum the cross products of consecutive edges, a positive total indicates counter‑clockwise order, a negative total clockwise. The cross product of 2d vectors is thus the basis for robust orientation predicates.
For instance, in a triangle with vertices $P_1=(0,0)$, $P_2=(2,0)$, $P_3=(1,2)$, the edge vectors are $\mathbf{a}=P_2-P_1=(2,0)$ and $\mathbf{b}=P_3-P_1=(1,2)$. The operation for these edges gives $2\cdot2 – 0\cdot1 = 4 > 0$, so the triangle is oriented counter‑clockwise.
Real‑world example: Suppose you are implementing a 2D maze generator. To test whether a point lies inside a polygon, you sum the signed areas of triangles formed by the point and each edge. If the total area is not zero, the point is outside. This technique relies entirely on the cross product of 2d vectors. Another practical use is in pathfinding: the operation can quickly tell you if a turn is left or right, which is essential for computing convex hulls.
Properties and Applications of the Cross Product of 2D Vectors
Here are the essential algebraic properties of the cross product of 2d vectors:
- Antisymmetry: $\mathbf{a}\times\mathbf{b} = -(\mathbf{b}\times\mathbf{a})$.
- Bilinearity: $(\alpha\mathbf{a}+\beta\mathbf{b})\times\mathbf{c} = \alpha(\mathbf{a}\times\mathbf{c}) + \beta(\mathbf{b}\times\mathbf{c})$.
- Relationship to dot product: $(\mathbf{a}\times\mathbf{b})^2 + (\mathbf{a}\cdot\mathbf{b})^2 = |\mathbf{a}|^2|\mathbf{b}|^2$ (a 2D form of the Lagrange identity).
Now let’s see where the scalar cross product shines:
| Application | How the operation is used | Example |
|---|---|---|
| Physics – Torque | In 2D, torque $\tau$ is the scalar cross product of position vector and force: $\tau = \mathbf{r}\times\mathbf{F}$. | A force of 10 N at 2 m lever arm gives torque $2\cdot10\cdot\sin90^\circ = 20$ N·m if perpendicular. |
| Graphics – Collision | Test which side of a line a point lies on using the cross product of edge and vector to point. | For edge $AB$ and point $P$, compute $(B-A)\times(P-A)$; sign tells left or right. |
| Geometry – Polygon area | Sum the cross products of consecutive vertices to get twice the polygon area. | Shoelace formula uses $\frac12\sum (x_i y_{i+1} – y_i x_{i+1})$. |
In computer graphics, the scalar cross product is the backbone of the edge function used in triangle rasterisation. Because it computes signed area cheaply, GPUs use it to determine which pixels lie inside a triangle. The cross product of 2d vectors also appears in algorithms for line intersection, convex hull construction (e.g., Graham scan), and determining the orientation of three points (the “orient” predicate).
For additional insight into vector multiplication methods, see our guide on multiplying vectors. For a rigorous treatment of the underlying mathematics, the Georgia Tech interactive linear algebra textbook provides an excellent foundation.
Common Mistakes with the Cross Product of 2D Vectors
Even experienced developers trip over these. Here is what you need to watch for when working with the cross product of 2d vectors:
Many students write $a_x b_x + a_y b_y$ instead of $a_x b_y – a_y b_x$. Remember: cross product uses subtraction and cross‑multiplied components.
If $a_y$ or $b_y$ is negative, the product $a_y b_x$ can become positive. Double‑check: $(-2)\cdot3 = -6$, but then subtracting a negative flips sign.
The 2D cross product is a scalar, not a vector. It is the magnitude of the perpendicular component, not a direction. Keep that distinction clear.
Another common error is using the cross product of 2d vectors in a 3D context without realizing that in 2D only one component exists. If you try to compute a 3D cross product from 2D coordinates, you must pad them with a zero z‑component and the result will be a vector (0,0, scalar). But the scalar itself is the 2D cross product. Always verify whether your application expects a scalar or a vector.
Finally, when computing the area of a polygon using the shoelace formula, ensure that you sum the cross products of consecutive vertices in the correct order (either clockwise or counter‑clockwise). A reversed order yields a negative area, which is correct for signed area, but if you need absolute area you must take the absolute value.
Frequently Asked Questions
What is the cross product of 2D vectors?
The cross product of 2D vectors is a scalar equal to $a_x b_y – a_y b_x$, representing the signed area of the parallelogram the vectors span.
Is the cross product of 2D vectors a scalar or a vector?
It is a scalar, not a vector. In 2D, the result is a single number that can be positive, negative, or zero.
How is the 2D cross product used in physics?
It computes torque: $\tau = \mathbf{r} \times \mathbf{F}$, where $\mathbf{r}$ is the position vector and $\mathbf{F}$ is the force vector, and the result is a scalar representing rotational effect.
What does a positive cross product mean?
If the cross product is positive, the second vector is counter‑clockwise from the first vector. Negative means clockwise.
Can the 2D cross product be zero?
Yes, if the vectors are parallel or anti‑parallel, or if one is zero. It indicates no area is spanned.
How do you compute the area of a triangle using the cross product?
For triangle vertices $A$, $B$, $C$, area $= \frac{1}{2} |(B-A) \times (C-A)|$, where the cross product is the 2D scalar version.
This concludes our comprehensive look at the cross product of 2d vectors. Understanding this operation gives you a powerful tool for geometry, physics, and graphics. Practice with a few examples, and you will find yourself using it instinctively.