Question
The Pythagoras tree is named after the Greek mathematician Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used
The Pythagoras tree is named after the Greek mathematician Pythagoras because each triple of touching squares encloses a right triangle, in a configuration traditionally used to depict the Pythagorean theorem. It is a plane fractal constructed from squares invented by the Dutch mathematics teacher Albert E. Bosman in 1942. In 1957 Bosman published a book on Het wondere onderzoekingsveld der vlakke meetkunde ("the wondrous exploration field of plane geometry") that contained a description of the Pythagorean tree. If the largest square has a size of L L, the entire Pythagoras tree fits snugly inside a box of size 6L 4L. Your task is to write a program PTree.cpp with a recursive function pTree(), and a main() program that calls the recursive function.
Your program shall take two command-line arguments L and N:
L size of the base square (double)
N the depth of the recursion
You should create a PTree class that derives from sf::Drawable.
Then, you can have it just draw itself to your main window.
Review Jon's LineSegment example to see a simple example of how to do this: LineDemo.tar.gz.
Using SFML's ConvexShape class is a good way to draw a square.
Your executable must read two parameters (integers): recursion-depth and window-size. You should create a square SFML window that's exactly as big as the window-size argument, and your triangle should fill it.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started