LSYSTEMS VISUALIZATION WITH TURTLE GRAPHICS LSYSTEMS WERE INVENTED

  • Slides: 11
Download presentation
L-SYSTEMS VISUALIZATION WITH TURTLE GRAPHICS

L-SYSTEMS VISUALIZATION WITH TURTLE GRAPHICS

L-SYSTEMS WERE INVENTED TO MODEL A RANGE OF NATURALLY OCCURRING SYSTEMS

L-SYSTEMS WERE INVENTED TO MODEL A RANGE OF NATURALLY OCCURRING SYSTEMS

L-SYSTEMS ARE STRING REWRITING MACHINES They consist of: • An initial state (called an

L-SYSTEMS ARE STRING REWRITING MACHINES They consist of: • An initial state (called an axiom) • Rewrite (production) rules which determine how a given input string is converted to an output string • This creates a feedback loop which operates on strings

VISUALIZING WITH TURTLE GRAPHICS • Imagine a turtle with a pen moving in the

VISUALIZING WITH TURTLE GRAPHICS • Imagine a turtle with a pen moving in the plane. The turtle can drag the pen while it walks to write or lift the pen which leaves no mark.

INSTRUCTIONS FOR THE TURTLE • F move forward a fixed length d and draw

INSTRUCTIONS FOR THE TURTLE • F move forward a fixed length d and draw a line segment along the way • f • + • - move forward a length d but do not draw turn left (counterclockwise) by a fixed angle α turn right (clockwise) by the angle α

AN EXAMPLE OF A SIMPLE L-SYSTEM • Axiom: F • Production Rule: F →

AN EXAMPLE OF A SIMPLE L-SYSTEM • Axiom: F • Production Rule: F → F + F - - F + F • Parameter: α = 60 degrees So now let us iterate the system: Axiom: F Stage 1: F + F - - F + F Stage 2: F + F - - F + F + F - - F + F

SYMBOLICALLY THIS DOES NOT SAY MUCH BUT LET IS LOOK AT IT GRAPHICALLY Axiom:

SYMBOLICALLY THIS DOES NOT SAY MUCH BUT LET IS LOOK AT IT GRAPHICALLY Axiom: F Stage 1: F + F - - F + F Stage 2: F + F - - F + F--F+F+F+F--F+F

CONTINUING THIS PRODUCES A CLASSIC FRACTAL CALLED THE KOCH CURVE. 3 COPIES YIELDS THE

CONTINUING THIS PRODUCES A CLASSIC FRACTAL CALLED THE KOCH CURVE. 3 COPIES YIELDS THE KOCH SNOWFLAKE

A SAMPLE L-SYSTEM GENERATOR • Ideas for software engineering project: v Create an L-System

A SAMPLE L-SYSTEM GENERATOR • Ideas for software engineering project: v Create an L-System generator with other built in examples v v Allow user to enter their own system Allow for “branching” (this will utilize a stack to store and retrieve portions of the output string) v Allow for non-deterministic (probabilistic) models which can be mores realistic v Context sensitive (as opposed to context free) systems v Other directions can be included based on student interests!