Making Generative Art With Triangles

Karl Rombauts
6 min readAug 14, 2022

Last week in my advanced algorithms class, our lecturer posed a simple puzzle to play around with.

Given a rectangle, for what values of n can it be divided into right-angle triangles?

More simply put, can you cut a rectangle into 1, 2, 3, … right-angled triangles? After some thought, you might realise that any right-angled triangle can always be cut into two separate right-angled triangles.

As an added bonus, all three triangles are similar triangles (this is not too hard to prove and is left as an exercise for the reader)

And because we can easily cut a rectangle along one of its diagonals to form two right-angled triangles, it should follow that we can always cut a rectangle into n ≥ 2 right-angled triangles.

Lots and lots of triangles!

So what? Firstly, not every problem needs a practical application. But secondly, we have just discovered a pattern that we can infinitely subdivide! So let’s explore this a bit further.

Data Structure

First thing’s first, let’s see if we can organise our triangles into a data structure. The process of subdividing triangles involves splitting one triangle into two children. This parent-child relationship can be nicely modelled using a binary tree.

--

--