hpc.social


High Performance Computing
Practitioners
and friends /#hpc
Share: 
This is a crosspost from   Cleve’s Corner: Cleve Moler on Mathematics and Computing Cleve Moler is the author of the first MATLAB, one of the founders of MathWorks, and is currently Chief Mathematician at the company. He writes here about MATLAB, scientific computing and interesting mathematics.. See the original post here.

L-systems, Plants, Fractal Curves, Turtles and Dragons

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.

Contents

L-systems

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

MLogo

Logo 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 degrees
s = A+A-A-A+

Dragon Curve

The dragon space-filling fractal curve was invented by NASA physicist John Heighway and his colleagues and featured in Martin Gardner's Scientific American column in 1967. I made a Cleve's Corner posting about the dragon curve in 2018.

Here is MLogo's dragon.

Here is a frame from "Numberphile" video where Brady Haran visits Don Knuth and the unique ceramic tile dragon in his home.

Hilbert Curve

David Hilbert (1862-1943), one of the most influential mathematicians of his era, introduced the space-filling fractal Hilbert curve in 1891.

Here is MLogo's Hilbert curve.

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

https://xkcd.com/195

Gosper Fractal

Bill Gosper, 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.

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

https://www.etsy.com/shop/DragonNerd

Algorithmic Beauty of Plants

"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 Springer Nature. A PDF version is available from AlgormicBotany at the University of Calgary.

This is MLogo's rendition of one small example.

Software

https://blogs.mathworks.com/cleve/files/MLogo.m


Get the MATLAB code

Published with MATLAB® R2024b