Scratch Painting Fractal Geometry Series 35: L System Painting Ceratophyllum demersum

Scratch Painting Fractal Geometry Series 35: L System Painting Ceratophyllum demersumPreviously, we used recursion to draw trees, ferns, shrubs and other plants. This time, we draw a similar but more complex plant fractal - Ceratophyllum demersum algae

Scratch Painting Fractal Geometry Series 35: L System Painting Ceratophyllum demersum

Previously, we used recursion to draw trees, ferns, shrubs and other plants. This time, we draw a similar but more complex plant fractal - Ceratophyllum demersum algae. It is composed of five rules VWXY and Z calling each other, and stack pushing [and stack pulling] appears in the L-system. In order to realize stack pushing, you can define a "save position" and a "return to position" subroutine in Scratch to complete it.

Draw the L Axiomatic system of Ceratophyllum demersum as follows:

Axiom: VZFFF

Rule: V> YV

W>+ X [- W] Z, X>- W [+X] Z

Y> YZ, Z -> [- FFF] [+FFF] F

Corner: 20 degrees

Symbol meaning: []: Draw lines for VWXYZF during stack pushing and stack pushing,

+: Left turn 20 degrees, -: Right turn 20 degrees

2. Recursive subroutine for drawing line F:

3. Draw the recursive sub building block code of Ceratophyllum demersum rule V and W:

4. Draw the recursive subprogram of Ceratophyllum demersum rule X and Y:

5. Draw the recursive subroutine of Ceratophyllum demersum rule Z:

6. Main program of drawing Ceratophyllum demersum algae:

7. 1~10 level fractal diagram of Ceratophyllum demersum:

Observation: with the increase of the number of stages, the higher the figure, if you want to get a higher level of Ceratophyllum demersum fractal figure, the expansion coefficient should be properly adjusted; Have you found that the shape of the branching parts is also very similar to the overall shape? This is often called the "Self-similarity" of fractal. Pay attention to experience.


Disclaimer: The content of this article is sourced from the internet. The copyright of the text, images, and other materials belongs to the original author. The platform reprints the materials for the purpose of conveying more information. The content of the article is for reference and learning only, and should not be used for commercial purposes. If it infringes on your legitimate rights and interests, please contact us promptly and we will handle it as soon as possible! We respect copyright and are committed to protecting it. Thank you for sharing.(Email:[email protected])