MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB技术文章 (https://www.labfans.com/bbs/forumdisplay.php?f=25)
-   -   L-systems, Plants, Fractal Curves, Turtles and Dragons - Cleve Moler on Mathematics and Computing (https://www.labfans.com/bbs/showthread.php?t=27461)

poster 2025-05-04 08:02

L-systems, Plants, Fractal Curves, Turtles and Dragons - Cleve Moler on Mathematics and Computing
 
No, this is not the script for an episode of "Game of Thrones". It is a blog post about Lindenmayer grammars, growing plants, space-filling fractals, turtle graphics and dragon curves.

Here is the opening screen from our new program, MLogo.

[IMG]http://blogs.mathworks.com/cleve/files/MLogo.png[/IMG]

[B]Contents[/B]
[LIST][*][URL="#e4c73f18-5203-41ab-aae7-29dfc3c677bc"]L-systems[/URL][*][URL="#2b729287-e100-42ba-9e7f-ceab5a7a41a4"]MLogo[/URL][*][URL="#fb091433-870d-4ce0-82f6-4310e751f537"]Dragon Curve[/URL][*][URL="#984588f4-4cb8-4fa5-8978-ec6e07b244b2"]Hilbert Curve[/URL][*][URL="#27758267-deb0-4d68-9287-7f7af46ef0ec"]Gosper Fractal[/URL][*][URL="#164f12f3-6e87-42af-b4e5-b38dd5d03010"]Algorithmic Beauty of Plants[/URL][*][URL="#b0adc2d3-245d-4aca-b9f1-6a19fc7af2f3"]Software[/URL][/LIST][B]L-systems[/B]

Aristid Lindenmayer (1925-1989) was a Hungarian biologist and botanist at the University of Utrecht. In 1968 he introduced a formal grammar for string rewrite rules that can describe living plants, artificial fractals, and especially, artificial fractals that model living plants.

Lindenmayer's strings drive MLogo. A simple example is

R = @(s) replace(s,"A","A+A-A");If you start with

s = "A"and repeat

s = R(s)three times, the result is

A A+A-A A+A-A+A+A-A-A+A-A A+A-A+A+A-A-A+A-A+A+A-A+A+A-A-A+A-A-A+A-A+A+A-A-A+A-A[B]MLogo[/B]

[URL="https://en.wikipedia.org/wiki/Logo_(programming_language)"]Logo[/URL] is a programming language, aimed at young students, developed in 1967 by MIT professors Wally Feurzeig, Seymour Papert, and Cynthia Solomon. Logo has been very influential, spawning hundreds of implementations and successors. MLogo, short for MATLAB Logo, is another successor.

A distinctive feature of Logo offprings is "turtle graphics". Basic Logo commands like step, turn, and draw drive a virtual tortoise, originally a motorized toy, and later a graphics cursor. Here is a sample with turtle driven by this Lindenmayer system.

A step forward+ turn left 90 degrees- turn right 90 degreess = A+A-A-A+[IMG]http://blogs.mathworks.com/cleve/files/Turtle-2.gif[/IMG]

[B]Dragon Curve[/B]

The dragon space-filling fractal curve was invented by NASA physicist John Heighway and his colleagues and featured in Martin Gardner's [I]Scientific American[/I] column in 1967. I made a [URL="https://blogs.mathworks.com/cleve/2018/04/06/the-dragon-curve"]Cleve's Corner[/URL] posting about the dragon curve in 2018.

Here is MLogo's dragon.

[IMG]http://blogs.mathworks.com/cleve/files/Dragon-1.gif[/IMG]

Here is a frame from "Numberphile" video where Brady Haran visits [URL="https://www.youtube.com/watch?v=v678Em6qyzk"]Don Knuth[/URL] and the unique ceramic tile dragon in his home.

[IMG]http://blogs.mathworks.com/cleve/files/Knuth.png[/IMG]

[B]Hilbert Curve[/B]

[URL="https://en.wikipedia.org/wiki/David_Hilbert"]David Hilbert[/URL] (1862-1943), one of the most influential mathematicians of his era, introduced the space-filling fractal [URL="https://en.wikipedia.org/wiki/Hilbert_curve"]Hilbert curve[/URL] in 1891.

Here is MLogo's Hilbert curve.

[IMG]http://blogs.mathworks.com/cleve/files/Hilbert.gif[/IMG]

Here is a crazy application of the Hilbert curve, Randall Munroe's view of Internet addresses in 2006, [URL]https://xkcd.com/195[/URL].

[IMG]http://blogs.mathworks.com/cleve/files/xkcd.png[/IMG]

[URL]https://xkcd.com/195[/URL]

[B]Gosper Fractal[/B]

[URL="https://en.wikipedia.org/wiki/Bill_Gosper"]Bill Gosper[/URL], one of the original MIT "hackers", has made major contributions to Lisp and Macsyma, found the "glider gun" for Conway's Game of Life, and invented the Gosper fractal.

Here is MLogo's rendition.

[IMG]http://blogs.mathworks.com/cleve/files/Gosper-1.gif[/IMG]

Dragon Nerd creates jewelry from the Gosper curve and other fractals.

[IMG]http://blogs.mathworks.com/cleve/files/DragonNerd.png[/IMG]

[URL]https://www.etsy.com/shop/DragonNerd[/URL]

[B]Algorithmic Beauty of Plants[/B]

"The Algorithmic Beauty of Plants" is a beautiful book by Przemyslaw Prusinkiewicz and Aristid Lindenmayer, featuring over fifty color figures of computer-generated plants. The original book is available from [URL="https://link.springer.com/book/10.1007/978-1-4613-8476-2"]Springer Nature[/URL]. A PDF version is available from [URL="https://algorithmicbotany.org/papers/#abop"]AlgormicBotany[/URL] at the University of Calgary.

[IMG]http://blogs.mathworks.com/cleve/files/abop.png[/IMG]

This is MLogo's rendition of one small example.

[IMG]http://blogs.mathworks.com/cleve/files/Plant-2.gif[/IMG]

[B]Software[/B]

[URL]https://blogs.mathworks.com/cleve/files/MLogo.m[/URL]

[RIGHT][COLOR=gray][I]
[URL="javascript:grabCode_038066df016b4e6685a8571703c3f9db()"][I]Get the MATLAB code (requires JavaScript)[/I][/URL]

Published with MATLAB® R2024b
[/I][/COLOR][/RIGHT]


所有时间均为北京时间。现在的时间是 01:04

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.