Oriented Areas and the Shoelace Formula

[August 6, 2018]

Here’s a summary of the concept of oriented area and the “shoelace formula”, and some equations I found while playing around with it that turned out not to be novel.

I wanted to write this article because I think the concept deserves to be better popularized, and it is useful to me to have my own reference on the subject. Some resources I have found, including Wikipedia, cite a 1959 monograph entitled Computation of Areas of Oriented Figures by A.M. Lopshits, originally printed in Russian and translated to English by Massalski and Mills, which I have not been able to find online. I did find a copy via university library, and I thought I would summarize its contents in the process to make them more available to a casual Internet reader.

I also wanted to practice making beautiful math diagrams. Which went okay, but god is it ever not worth the effort.


1

Let be a polygon with vertices . Sometimes I will refer to also, which is defined to equal , because it makes formulas neater.

Here’s a with :

The signed or oriented area of is given by the so-called “shoelace formula”:

where the sum wraps around, thanks to being the same as . Each term is the area of the triangle formed by the origin, , and .

It’s called the shoelace formula because when you write all the coordinates in a column and begin to compute the cross products by multiplying , , etc, it’s reminiscent of a laced shoe:

“Signed” area means that the area is positive if its vertices go counterclockwise, and is negative if its vertices go clockwise.

You can remember which is which because counterclockwise / positive is also the direction that positive radians go, by convention. This is arbitrary, and we could have defined it the other way. If you just want the unsigned area of a region, you can always take the absolute value of this, so the signed area is strictly more powerful than the unsigned version.

Signed areas are useful because they are better-behaved than regular areas in several ways. The signed area of a shape is preserved under any decomposition into component shapes, with negatively-oriented components subtracting from the total area:

I’ve indicating that the circle is negatively oriented and thus has negative area with an arrow that says it is to be traversed clockwise. Its area is subtracted from the total area of the rectangle, giving the area of the composite shape automatically.

This becomes more useful in more complicated figures, because it lets us build them out of simple parts very cleanly. The shoelace formula works because of the ability to add these oriented areas without having to specify which ones to subtract. It amounts to decomposing a shape into a list of triangles with the origin as the third vertex, and adding their areas. This is totally natural if the origin is fully contained within the polygon:

But signed areas mean that this construction works even if the origin is outside the polygon, with the triangles overlapping, because their overlapping parts cancel perfectly:

The dark areas cancel out of the total sum, because the (negative) area of exactly cancels the excess positive areas in each of the other triangles , and .

The coordinate-invariance of this formula (that it works regardless of where is) should be enough to motivate it as mathematically valuable. We like formulas that don’t care about specific coordinate systems.

We’re used to dealing with what are called simple polygons – polygons whose sides never overlap, so they surround a single region of space without any intersections. We can also consider non-simple polygons, which are allowed to have their vertices or edges overlap or intersect. The shoelace formula continues to work if the polygon is non-simple, except we must understand that negatively-oriented regions subtract from the total sum instead of adding, which may not be totally intuitive:

The total signed area here is zero, because the two oppositely-oriented components have the same magnitudes of areas, but opposite signs, so they cancel out.


Related to the concept of oriented area is the concept of oriented angle, which is actually a bit more familiar. Oriented angles distinguish between “the angle between and ” and “the angle between and ”, by insisting that we specify counterclockwise angles (the way radians go) as positive:

This is very much like how the vector is the negative of the vector . In fact it is appealing to think of oriented angles as some kind of curved vectors – we can add and subtract ‘angular’ vectors just like regular vectors. In this example, evidently , and this angle addition formula holds whether or not falls between and :

We want to think of angles as oriented because we can use them in formulas to get oriented areas as results. The cross product of two vectors gives the signed area of the parallelogram , regardless of their relative orientation:


2

The shoelace formula can be massaged into some other forms. Defining as the vector displacements of each side1:

Which is just the same polygon labelled differently:

Then we can write the area as:

Since and is distributive, this is the same as (1). Essentially we are just referring to our triangles differently, by and instead of and :

The vectors traverse the polygon starting at :

They form a closed loop (). Therefore we can eliminate the terms from the area formula entirely by writing them as sums of displacements (recalling that cancels out because it equals ):

This is the shoelace formula, rewritten to only use the vector displacements of the figure.


Finally, we can write this in terms of just the side-lengths and exterior vertex angles of the polygon.

We may describe the angles of a polygon in several ways. The first is by the interior angle at vertex , with the stipulation that this is always the angle measured counterclockwise from the first side in our oriented order, so that it is always the interior on positively-oriented simple polygons:

Interior angles are probably the most intuitive, but they perform less well in equations than the exterior angle at each vertex, which is the angle between the vectors and . Let’s call them , so is the exterior angle at the point :

Evidently . Also, for a simple polygon, the sum of all the angular displacements at every vertex must add up to , because the angles make one complete circle.

In a regular -gon, each exterior angle must be equal, so , which means the interior angles are and the sum of the interior angles is .

The area of a regular -gon is created from copies of the right triangle that has as one of its angles, which gives various formulas for computing their area depending on what lengths you have:

We can see that these relationships should hold, in case you’d like to go calculating some values from the others:

For a simple, positively-oriented polygon, the exterior angles add up to exactly radians. For non-simple polygons they may add up to any multiple of depending on how many clockwise or counterclockwise loops there are:

The first figure has , the second has , and the third has .

Each adjacent displacement vector differs from the previous vector by the exterior angle between them .

Therefore we can find the angle between any two displacement vectors by adding up all the exterior angles between them: (with the sum wrapping around if need be, and with addition be modulo ):

We can use this in to get a version of the area formula expressed only in lengths and exterior angles:

By labeling the side lengths as and expanding the sum over before , we can get to a form which which is presented on Wikipedia:

This and (4) are two ways of expressing the same idea: the area of a polygon in terms of scalar lengths and angles. I am not sure when you would ever want to use these, though – these loops have steps in them, while the original formula (1) involved only .


3

As mentioned, the Wikipedia article on polygons sources formula (5) from Computation of Areas of Oriented Figures by A.M. Lopshits, published 1959. It turns out some other people have chased that link and also cited this text, but I could not get my hands on a .pdf version, so I got it from the university library.

If you are curious what it contains, here’s an outline. The short version is: not much. I wanted more formulas and ideas in the vein of (5), but much deeper. Turns out, though, that’s it’s a mostly pedagogical text that reaches that formula as its final result after spending 40 pages on the concept of oriented area and related (elementary) geometric proofs.

Outline of Computation of Areas of Oriented Figures by AM Lopshits

Chapter 1. Measurement of the Area of an Oriented Figure

  1. Oriented triangles are a lot like regular triangles, but oriented.
  2. Oriented triangles have oriented areas.
    • The simplest way to see that this might be useful is this:
    • Consider a triangle . If is a point on the line segment , then .

    • If we allow ourselves oriented triangles and areas, this remains true even if is a point on the line , but outside the triangle:

    • Lopshits makes all of these points arduously, in multiple theorems with elaborate proofs. I suspect the mid-century Russians loved proving things arduously.
  3. The area of an oriented triangle can be calculate using the shoelace formula for any choice of origin .
    • this is carefully proven using previous theorems.
  4. Oriented polygons are oriented collections of points. The shoelace formula gives their area for any choice of .
    • this is also carefully proven using previous theorems.
  5. Some examples and exercises. The most interesting set is like this (for ):

    “A regular dodecagon is inscribed in a circle. The polygon has three points of self-intersection, , , . Prove that the area of the triangle is three times the area of the triangle .”

Chapter 2. The Planimeter

  1. This chapter entirely describes the workings of a device called the planimeter, which is used to measure [signed] areas of printed curves via, essentially, the shoelace formula acting on a polygonal approximation.
    I do not care about planimeters, though I’m sure this was interesting in 1959.
    In fact it turns out there are multiple kinds of planimeters out there, each of which the reader is invited to deeply contemplate.
    There is one theorem I found interesting, though:
  2. “Imagine a directed segment in the plane. Let us move it around the plane, finally bringing it back to its original position. In this motion the end and will of course trace out closed curved and . Also, will sweep out an oriented area .”
    Theorem:

    This is simple to convince yourself of – as oriented areas, we must have , and one of the areas must be oppositely-oriented so we may pick to be negative.

Chapter 3. Computation of the Area of a Polygon Useful in Surveying

  1. This section primarily produces my formula (5). The argument for its use in surveying is that the formula uses only scalar lengths and angles, meaning that one can find the area of unwieldy regions (say, a plot of land) by measuring all the lengths and angles individually and then computing the result.
  2. But before getting to that formulation, Lopshits introduces the concept of vectors. I am not understanding what level this text is meant for.
  3. Derives of equation (4), though without summation formulas.
  4. Oriented angles work better than regular ones for this calculation.
  5. Lot of words about computing what I have called .
  6. Derivation of equation (5), for which Lopshits was cited on Wikipedia.

And that’s pretty much… it. I’m a little disappointed.


4

It’s worth discussing how the shoelace formula is related to integral calculus. After all, if anything is the ‘canonical’ way to calculate area, it’s an area integral: .

Green’s theorem says how we can translate an area integral over a region into an integral over its boundary. Specifically, it says that an area integral over a region is equivalent to certain a line integral around the boundary of the region. If and are functions with continuous partial derivatives in a region bounded by an (oriented!) curve , then:

For the simple case of , we just need to find any which have . This is easily done with either , , or any combination of them, like . Therefore each of these gives an integral for area:

The connection is this:

Suppose we are computing , ie, computing a line integral around the boundary of an oriented polygon from before. Then, for the entire segment of the integral along the side , the tangent direction is parallel to . Obviously these sums of ‘infinitesimal’ triangles along the side should add up to give the finite-sized triangle area of :

To be a bit more explicit, we can parameterize the curve along a side by , so that . Then , and:

Adding the contributions from every side give:

I’m sure there is some reason why this is not entirely rigorous, but it explains why it works perfectly.


While we’re at it, maybe we can come up with an ‘integral form’ of (3) or (4). Naively, it should look something like this, right?

Where we parameterize the curve enclosing our region as for .

This is just taking the integral formula and replacing with , which should be fine as long as [mumbled analytical argument]. If we separate into and we should get a version of (5), also.


5

The fact that the shoelace formula is a consequence of Green’s theorem means that there should be a way to take it to higher dimensions. Green’s theorem readily generalizes to Stoke’s Theorem in arbitrary spaces, which says that the integral of a function (or differential form) over a closed surface can be equated to the integral of its derivative through the enclosed volume:

This means that:

  • the shoelace formula should continue to calculate the areas of oriented polygons in dimensions
  • there should be an analog to the shoelace formula for computing volumes, 4-volumes, etc

For now I will mention how to calculate area in 3D, because it looks a little different than in 2d.

Area of a figure in 3d: Suppose we want to compute the area of the triangle:

We can compute the shoelace answer:

But that’s… not a scalar. What went wrong?

The answer is that this the area of represented as a vector, which is normal to the plane of . It tells you more than the area – it also tells you what direction the area faces. To get to the scalar area, though, you have to take its magnitude:

But you lose the sign when taking the magnitude – the direction of that vector was what was telling us the orientation. In 3D, it’s meaningless to say that a surface is ‘positively’ oriented – what if it’s orthogonal to the plane? Should that be positive or negative? What if we flip it over? Orientation cannot be an intrinsic property of a shape if it changes as we rotate things!

Instead we can just talk about how things are oriented relative to each other. A figure on the plane is either oriented in the direction or the direction. In 2D we drop the ’s and just call this positive and negative. In 3D, though, volumes have an absolute concept of orientation, but in 4D they would not – they would just end up oriented to the, say, or axes!

The shoelace formula used on a general polygon in 3D will work the same way, giving a vector. Note that this does require the polygon to be already known to be planar, or the answer you get will be meaningless.

By the way – if you want to compute the surface area of a figure by summing the areas of each side, go right ahead, but make sure you normalize each side’s area to be positive first. The surface area vectors of a closed figure in 3D will always cancel out to . (Why? Because of Stoke’s theorem: .)


As for volumes – that will have to wait for another article. Higher-dimensional shapes like polyhedra are much harder to deal with than polygons, primarily because it’s just hard to represent them. It’s not enough to supply a list of vertices , because you also needs to specify which sets of vertices make each face, and to ensure that the faces are oriented consistently: if the edge appears on one face, then must appear on the other face that shares that edge.

I will say only that if you do have a list of oriented polygonal faces , then the volume of the pyramid created by a face with the origin is given by

( just has to be any point on the face – we’re summing the volumes of the tetrahedrons , and we need any third point in order to turn areas into volumes. in this case is the area vector, not the scalar.)

Then the volume of the whole figure is given by:


6

That’s all I’ve got, for now. Hope it’s useful, interesting, or otherwise not a total waste of time. I hope to revisit higher-dimensional shoelace-type formulas at some point, but it’ll have to wait. This was exhausting (well, making it pretty was).

I made the diagrams using Tikz, which is what all those fancy diagrams in LaTeX documents and textbooks are made in, and it was a lot of work but I’m glad I’ve started to learn how to do it. The process of conveniently importing Tikz images into websites, though, is … not enjoyable. I would be so excited if there was a project like Mathjax that extracted a subset of Tikz for inline web-document creation.

  1. I like to use boldface to refer to things that are definitely vectors, as opposed to our which are points and cannot be added and subtracted.