Menger Recursion

753
0
Published 2024-02-04
Just a little illustration of the power of recursion, a method in which a function calls itself. If you look inside, you'll see the custom block using itself. It's not that easy to get your head around, but it's powerful.
The Menger cube (aka sponge) is suitable for the illustration - the idea is that you divide a cube up into smaller cubes, get rid of some of them, and then apply the same process to each of the smaller cubes, then to each of the even smaller cubes and so on.
There are plenty of excellent Menger projects on Scratch - raymarchers, ones that allow you to rotate the cube etc.