How to draw a pentagon using an L-system
The rules of L-systems can be used to generate shapes such as the pentagon. The basic rules of L-systems are:
F : move forward a distance
- : change direction and go clockwise
+ : change direction and go anti-clockwise
Since a pentagon has external angles of 72 degrees (as shown in the workings below), when using an L-system, you'd have to set the turn angle to that figure to generate the desired outcome.
So, to draw a pentagon, you'd need to use the rule:
F+F+F+F+F [Turn angle: 72 degrees]
And that would give you the correct drawing.
I learnt this method in the book 'Pattern Generation for Computational Art' by Stefan Hollos and J. Richard Hollos.
It contains very good tutorials about how to apply L-systems, so I would recommend it to anyone interested in this kind of computational art.
You can purchase this book via my affiliate link here: https://amzn.to/3DQe5Iw
Purchases made through my affiliate links help sustain this blog and my maths project, so many thanks if you do decide to get the book.
Comments
Post a Comment