This lab will follow examples from the wonderful book "The Algorithmic Beauty of Plants (ABOP)". This book is available free at the link, and is well worth perusing. We will be generating plants using the grammars and approach summarized in Figure 1.24, "Examples of plant-like structures generated by bracketed OL systems“, from that book For this problem, you will implement a class called PLANT. The class has two methods: (1) An initializer. The function will take an initial state (string), a generator (dictionary), the number of generation iterations to run (n) and an angle delta (deltaTheta) for changing direction while drawing. When the class is initialized, you must run the generator with the specified parameter, and make the resulting string available as a member variable PLANT.str. To run the generator, every character in the input string is either (a) replaced by the corresponding value from the generator dictionary if it is in the generator dictionary, or (b) copied directly to the output string if it is not in the generator dictionary. This is repeated n times. The resulting string is stored in the PLANT.str member variable. For example: myPlant - PLANT ('b', {'b':'a', 'a':'ab'},5,25) myPlant.str =-'abaababa' --> True and myPlant-PLANT ('X',{ 'X' : 'F[+X]F[-X]+X','F': 'FF'},2,20) myPlant.str='F [+F[+X]F(-X]+X]FF(-F(+X]F(-X]+X]+F[+X]F[-X]+X' --> True (2) A drawPlant method (no parameters). The draw method works as follows: • start with a currentPt=(200,0). This is the current draw location. • start with a theta of 90 degrees • any alphabet character e.g. (A'b'X) moves forward one step, drawing a line from currentPt to nextPt - (currentPt[0]+cos (theta), currentPt[1]+sin(theta)). ***This is the only drawing code you should use. Do not call pit show() or run any other test code except in your testing_main_block plt.plot([currPt[0],nextPt[0]],[currPt(1],nextPt[1]],color='black') After drawing, set currentPt-nextPt. • t saves current drawing state (currentPt, theta] on a stack (see Python Stack for details). • Tresets the currentPt and theta to the most recently saved drawing state from the stack. •* increases the current drawing angle theta by deltaTheta degrees. •" decreases the current drawing angle theta by deltaTheta degrees. The sample output provided in the file abop_1_24_a.png downloadable here was generated using the grammar given in figure 1.24(a) of АВОР The sample image was generated using p1t.axis('image') as well. Your plot from e.g. the main section does not need to look exactly like the sample png - just be sure to only use the plot command as given above. If in doubt, check with zyBooks
This lab will follow examples from the wonderful book "The Algorithmic Beauty of Plants (ABOP)". This book is available free at the link, and is well worth perusing. We will be generating plants using the grammars and approach summarized in Figure 1.24, "Examples of plant-like structures generated by bracketed OL systems“, from that book For this problem, you will implement a class called PLANT. The class has two methods: (1) An initializer. The function will take an initial state (string), a generator (dictionary), the number of generation iterations to run (n) and an angle delta (deltaTheta) for changing direction while drawing. When the class is initialized, you must run the generator with the specified parameter, and make the resulting string available as a member variable PLANT.str. To run the generator, every character in the input string is either (a) replaced by the corresponding value from the generator dictionary if it is in the generator dictionary, or (b) copied directly to the output string if it is not in the generator dictionary. This is repeated n times. The resulting string is stored in the PLANT.str member variable. For example: myPlant - PLANT ('b', {'b':'a', 'a':'ab'},5,25) myPlant.str =-'abaababa' --> True and myPlant-PLANT ('X',{ 'X' : 'F[+X]F[-X]+X','F': 'FF'},2,20) myPlant.str='F [+F[+X]F(-X]+X]FF(-F(+X]F(-X]+X]+F[+X]F[-X]+X' --> True (2) A drawPlant method (no parameters). The draw method works as follows: • start with a currentPt=(200,0). This is the current draw location. • start with a theta of 90 degrees • any alphabet character e.g. (A'b'X) moves forward one step, drawing a line from currentPt to nextPt - (currentPt[0]+cos (theta), currentPt[1]+sin(theta)). ***This is the only drawing code you should use. Do not call pit show() or run any other test code except in your testing_main_block plt.plot([currPt[0],nextPt[0]],[currPt(1],nextPt[1]],color='black') After drawing, set currentPt-nextPt. • t saves current drawing state (currentPt, theta] on a stack (see Python Stack for details). • Tresets the currentPt and theta to the most recently saved drawing state from the stack. •* increases the current drawing angle theta by deltaTheta degrees. •" decreases the current drawing angle theta by deltaTheta degrees. The sample output provided in the file abop_1_24_a.png downloadable here was generated using the grammar given in figure 1.24(a) of АВОР The sample image was generated using p1t.axis('image') as well. Your plot from e.g. the main section does not need to look exactly like the sample png - just be sure to only use the plot command as given above. If in doubt, check with zyBooks
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Please code in python
question is in the image
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education