Implementation of Fractal Binary Trees in python.
Introduction A fractal tree is known as a tree which can be created by recursively symmetrical branching.
The trunk of length 1 splits into two branches of length r, each making an angle q with the direction of the trunk. Both of these branches divides into two branches of length r*r, each making an angle q with the direction of its parent branch. Continuing in this way for infinitely many branching, the tree is the set of branches, together with their limit points, called branch tips.
So enough with the theory now let’s try to implementation in Python. To do so we require two python libraries pygame for GUI or graphical user interface and math which is a builtin library in python and will be used for mathematical tweakings.
To install pygame
pip install pygame
So how to proceed, its highly recommended that you know a bit about pygame and fractals.
First create a trunk and then start creating the branches for each trunk taking the size of the branches of the size equal to the 0.9*(length of the stem) and then again considering the branches as stem again and such repeating the process.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.