You are currently browsing the tag archive for the ‘Shoelace Algorithm’ tag.

If you are a teacher then please also visit my new site: intermathematics.com for over 2000+ pdf pages of resources for teaching IB maths!

**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): (x_{3}-x_{2})(y_{1}-y_{3})

And the area of triangles will be:

(1): 0.5(x_{3}-x_{2})(y_{2}-y_{3})

(2): 0.5(x_{1}-x_{2})(y_{1}-y_{2})

(3): 0.5(x_{3}-x_{1})(y_{1}-y_{3})

Therefore the area of triangle (4) will be:

Area = (x_{3}-x_{2})(y_{1}-y_{3}) – 0.5(x_{3}-x_{2})(y_{2}-y_{3}) – 0.5(x_{1}-x_{2})(y_{1}-y_{2}) – 0.5(x_{3}-x_{1})(y_{1}-y_{3})

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

x_{1 } = 2 x_{2 } = 1 x_{3 } = 3

y_{1 } = 3 y_{2 } = 2 y_{3 } = 1

Area = (x_{3}-x_{2})(y_{1}-y_{3}) – 0.5(x_{3}-x_{2})(y_{2}-y_{3}) – 0.5(x_{1}-x_{2})(y_{1}-y_{2}) – 0.5(x_{3}-x_{1})(y_{1}-y_{3})

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 (x_{1}, y_{1}) as (1,1) and then (x_{2}, y_{2}) 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.

Essential resources for IB students:

Revision Village has been put together to help IB students with topic revision both for during the course and for the end of Year 12 school exams and Year 13 final exams. I would strongly recommend students use this as a resource during the course (not just for final revision in Y13!) There are specific resources for HL and SL students for both Analysis and Applications.

There is a comprehensive Questionbank takes you to a breakdown of each main subject area (e.g. Algebra, Calculus etc) and then provides a large bank of graded questions. What I like about this is that you are given a difficulty rating, as well as a mark scheme and also a worked video tutorial. Really useful!

The Practice Exams section takes you to a large number of ready made quizzes, exams and predicted papers. These all have worked solutions and allow you to focus on specific topics or start general revision. This also has some excellent challenging questions for those students aiming for 6s and 7s.

**Essential Resources for IB Teachers**

If you are a **teacher** then please also visit my new site. This has been designed specifically for teachers of mathematics at international schools. The content now includes over **2000 pages of pdf content** for the entire SL and HL Analysis syllabus and also the SL Applications syllabus. Some of the content includes:

**Original pdf worksheets**(with full worked solutions) designed to cover all the syllabus topics. These make great homework sheets or in class worksheets – and are each designed to last between 40 minutes and 1 hour.**Original Paper 3 investigations**(with full worked solutions) to develop investigative techniques and support both the exploration and the Paper 3 examination.- Over 150 pages of
**Coursework Guides**to introduce students to the essentials behind getting an excellent mark on their exploration coursework. - A large number of
**enrichment activities**such as treasure hunts, quizzes, investigations, Desmos explorations, Python coding and more – to engage IB learners in the course.

There is also a lot more. I think this could save teachers 200+ hours of preparation time in delivering an IB maths course – so it should be well worth exploring!

**Essential Resources for both IB teachers and IB students**

1) Exploration Guides and Paper 3 Resources

I’ve put together a **168 page** Super Exploration Guide to talk students and teachers through all aspects of producing an excellent coursework submission. Students always make the same mistakes when doing their coursework – get the inside track from an IB moderator! I have also made **Paper 3 packs** for HL Analysis and also Applications students to help prepare for their Paper 3 exams. The Exploration Guides can be downloaded here and the Paper 3 Questions can be downloaded here.