The Shoelace Algorithm to find areas of polygons

The Shoelace Algorithm to find areas of polygons

This is a nice algorithm, formally known as Gauss’s Area formula, which allows you to work out the area of any polygon as long as you know the Cartesian coordinates of the vertices.  The case can be shown to work for all triangles, and then can be extended to all polygons by first splitting them into triangles and following the same approach.

Let’s see if we can work out the algorithm ourselves using the construction at the top of the page.  We want the area of the triangle (4), and we can see that this will be equivalent to the area of the rectangle minus the area of the 3 triangles (1) (2) (3).

Let’s start by adding some other coordinate points for the rectangle:

Therefore the area of the rectangle will be:

(1) + (2) +(3) +(4): (x3-x2)(y1-y3)

And the area of triangles will be:

(1): 0.5(x3-x2)(y2-y3)

(2): 0.5(x1-x2)(y1-y2)

(3): 0.5(x3-x1)(y1-y3)

Therefore the area of triangle (4) will be:

Area = (x3-x2)(y1-y3) – 0.5(x3-x2)(y2-y3) – 0.5(x1-x2)(y1-y2) – 0.5(x3-x1)(y1-y3)

Therefore we have our algorithm!  Let’s see if it works with the following coordinates added:

x1 = 2  x = 1  x = 3
y1 = 3 y = 2  y = 1

Area = (x3-x2)(y1-y3) – 0.5(x3-x2)(y2-y3) – 0.5(x1-x2)(y1-y2) – 0.5(x3-x1)(y1-y3)

Area = (3-1)(3-1) – 0.5(3-1)(2-1) – 0.5(2-1)(3-2) – 0.5(3-2)(3-1)

Area = 4 – 1 – 0.5 – 1 = 1.5 units squared

We could check this using Pythagoras to find all 3 sides of the triangle, followed by the Cosine rule to find an angle, followed by the Sine area of triangle formula, but let’s take an easier route and ask Wolfram Alpha (simply type “area of a triangle with coordinates (1,2) (2,3) (3,1)).  This does indeed confirm an area of 1.5 units squared.  Our algorithm works.  We can of course simplify the area formula by expanding brackets and simplifying.  If we were to do this we would get the commonly used version of the area formula for triangles.

The general case for finding areas of polygons

The general formula for the area of an n-sided polygon is given above.

For a triangle this gives:

For a quadrilateral this gives:

For a pentagon this gives:

You might notice a nice shoelace like pattern (hence the name) where x coordinates criss cross with the next y coordinate along.  To finish off let’s see if it works for an irregular pentagon.

If we arbitrarily assign our (x1, y1) as (1,1) and then (x2, y2) as (3,2), and continue in a clockwise direction we will get the following:

area = absolute of 0.5( 1×2 + 3×4 + 3×1 + 4×0 + 2×1 – 3×1 – 3×2 – 4×4 – 2×1 – 1×0)

area = 4.

Let’s check again with Wolfram Alpha – and yes it does indeed have an area of 4.

It could be a nice exploration task to take this further and to explore how many different methods there are to find the area of polygons – and compare their ease of use, level of mathematics required and aesthetic appeal.

IB teacher? Please visit my new site http://www.intermathematics.com ! Hundreds of IB worksheets, unit tests, mock exams, treasure hunt activities, paper 3 activities, coursework support and more. Take some time to explore!

Andrew Chambers: (Resources for IB teachers)

Are you a current IB student or IB teacher? Do you want to learn the tips and tricks to produce excellent Mathematics coursework?  Check out my new IA Course in the menu!

Andrew Chambers (Getting a 7 on IB Maths Coursework)

Leave a Reply

Powered by WordPress.com.

Up ↑

Discover more from IB Maths Resources from Intermathematics

Subscribe now to keep reading and get access to the full archive.

Continue reading