Shoelace Formula Calculator
Find the area of any polygon from its vertex coordinates, plus the signed shoelace sum, perimeter and centroid.
What it does
The shoelace formula finds the area of a polygon straight from the coordinates of its corners. You list the vertices in order around the edge, cross multiply neighbouring pairs and take half the difference of the two totals. It goes by several names, including Gauss's area formula and the surveyor's area formula, and Wolfram MathWorld notes the name comes from the way the cross products are written out, like the crossings of a shoelace.
Surveyors had a version of this long before calculators. If you know the corner points of a plot of land, you can get its area without walking diagonals or splitting the plot into triangles. The same arithmetic works for a triangle, a square, an L shaped room or a many sided figure, as long as the vertices are given in order. MIT's course notes on geometry describe the formula as half the sum of the two dimensional cross products of consecutive vertices, with the last vertex joined back to the first.
The sign of the result carries information. Run the vertices counterclockwise and the signed sum comes out positive; run them clockwise and it comes out negative. Taking the absolute value removes that difference, so the direction of travel does not change the area. The Illinois computational geometry notes explain that this sign reflects the orientation of the boundary and that the same sum counts overlapping pieces of a non convex polygon with cancellation.
This tool takes a vertex list, closes the loop for you and returns four numbers: the area, the signed shoelace sum, the perimeter and the centroid. It accepts decimal coordinates and negative coordinates, so graphs that straddle the origin work without any shifting.
The method assumes a simple polygon, meaning edges that meet only at shared corners. A figure with crossing edges will still produce a number, but that number is a signed combination of regions rather than a true enclosed area. Treat the result as a check on your vertex order, not as a substitution for a drawing.
How to use
- Write the vertices as x,y pairs, one pair per line or separated by semicolons.
- List them in order as you walk around the edge of the shape, in either direction.
- Enter whole numbers or decimals, including negatives, using the same scale on both axes.
- Repeat the first vertex at the end if your source data includes it; the tool drops the duplicate.
- Read the area first, then use the signed sum to tell which way the vertices run.
- Check the perimeter and centroid against a sketch to catch a swapped coordinate pair.
Formula
- A
- Area of the polygon, in square units of the coordinate grid.
- S
- Signed shoelace sum, twice the area with a sign for orientation.
- x_i, y_i
- Coordinates of vertex i in order around the boundary.
- n
- Number of vertices, which equals the number of edges.
- x(n+1), y(n+1)
- A repeat of the first vertex that closes the loop.
The product x_i times y_(i+1) runs down the list while y_i times x_(i+1) runs up, which is where the name comes from. The first vertex is paired with the last automatically. Because the sum is unchanged by translation, you can shift a whole figure to positive coordinates first if that makes the arithmetic easier, and the area will not change. The perimeter is the sum of edge lengths from Pythagoras, and the centroid is the area weighted average of the enclosed region.
Worked example
Example: a four sided figure from four coordinate pairs
Defaults: vertices 0,0; 6,0; 4,4; 1,3. They are already in counterclockwise order.
- List the corners with the first repeated at the end: (0,0), (6,0), (4,4), (1,3), (0,0).
- Downward products x_i times y_(i+1): 0*0 + 6*4 + 4*3 + 1*0 = 0 + 24 + 12 + 0 = 36.
- Upward products y_i times x_(i+1): 0*6 + 0*4 + 4*1 + 3*0 = 0 + 0 + 4 + 0 = 8.
- Shoelace sum S = 36 - 8 = 32, so the area is 32 / 2 = 16 square units.
- The positive sign of S confirms the counterclockwise order.
- Perimeter: 6 + sqrt(20) + sqrt(10) + sqrt(10) = 6 + 4.472 + 3.162 + 3.162 = 16.8 units.
- Centroid: (280 / 96, 152 / 96) = (2.92, 1.58). The tool shows area 16 sq units, signed sum 32 sq units, perimeter 16.8 units and centroid (2.92, 1.58).
Reference table
| Vertices in order | Downward sum | Upward sum | Signed sum | Area (sq units) |
|---|---|---|---|---|
| (0,0), (4,0), (0,3) | 12 | 0 | 12 | 6 |
| (0,0), (6,0), (4,4), (1,3) | 36 | 8 | 32 | 16 |
| (1,1), (4,1), (4,4), (1,4) | 34 | 16 | 18 | 9 |
| (0,0), (0,4), (4,4), (4,0) | 0 | 32 | -32 | 16 |
Limits
- Assumes a simple polygon. Edges that cross give a signed mix of regions, not a physical area.
- Only works for coordinates on a flat grid. Coordinates taken from a curved map need projecting first.
- The centroid returned is the geometric centroid of the enclosed region, which assumes uniform density.
- Very large coordinates can lose precision in floating point arithmetic; this tool caps each coordinate at one million.
Common mistakes
- Listing vertices in the order they appear in a table rather than the order around the shape.
- Forgetting to pair the last vertex back to the first, which drops one edge from the sum.
- Reading the signed sum as the area instead of halving it.
- Mixing x and y when typing a pair, which changes the shape and can make edges cross.
- Assuming a negative signed sum is an error. It only means the vertices run clockwise.
Try it yourself
Quick checks. Answers sit tucked under each question.
What area and perimeter does a triangle with vertices (0,0), (4,0) and (0,3) have?
Downward sum 0 + 12 + 0 = 12 and upward sum 0 + 0 + 0 = 0, so the signed sum is 12 and the area is 6 sq units. The edges are 4, 5 and 3, so the perimeter is 12 units and the centroid is (1.33, 1).
A square runs (1,1), (4,1), (4,4), (1,4). What do the four outputs show?
Downward sum 34 and upward sum 16 give a signed sum of 18, so the area is 9 sq units. Perimeter is 12 units and centroid is (2.5, 2.5).
A 4 by 4 square is listed as (0,0), (0,4), (4,4), (4,0). What changes compared with counterclockwise order?
The area stays 16 sq units, but the signed shoelace sum is -32 sq units because the vertices run clockwise. Perimeter is 16 units and centroid is (2, 2).
Questions
What does the shoelace formula compute?
The area of a simple polygon from the Cartesian coordinates of its vertices, taken in order around the boundary.
Why is it called the shoelace formula?
Writing the x list over the y list and drawing the cross multiplications produces a crisscross pattern like the laces on a shoe. MathWorld also lists the names Gauss's area formula and surveyor's formula.
Do the vertices need to be in a particular direction?
No. Clockwise and counterclockwise both give the same area after taking the absolute value. The sign of the raw sum only tells you the direction.
Can I use negative coordinates?
Yes. The formula is unchanged by translation, so points on either side of the origin work as they are.
What if I repeat the first vertex at the end?
That is the standard way to close the loop. The tool detects the duplicate last point and removes it before computing, so the answer is the same either way.
Does it work for shapes with holes?
Not directly. A hole needs its own boundary walked in the opposite direction and its area subtracted, or the region split into simple pieces first.
Sources
- MIT OpenCourseWare, 18.900 Geometry and Topology: The Shoelace Formula and the Winding Number
- Wolfram MathWorld, Shoelace Formula
- University of Illinois, Computational Topology notes: Shoelaces and Signed Areas