smithers.extras
Class Lindenmayer

java.lang.Object
  extended by smithers.extras.Lindenmayer

public class Lindenmayer
extends java.lang.Object

Implements Lindenmayer systems and displays output with turtle graphics.


Constructor Summary
Lindenmayer(java.lang.String axiom, java.util.Map<java.lang.String,java.lang.String> rules)
          Creates a new Lindenmayer system.
 
Method Summary
static java.lang.String evolveToString(java.lang.String axiom, java.util.Map<java.lang.String,java.lang.String> rules, int steps)
          Creates a Lindenmayer system, evolves it for a number of steps, and outputs as a string.
static void evolveToTG(java.lang.String axiom, java.util.Map<java.lang.String,java.lang.String> rules, int steps, double angle, double distance, double x, double y, double dir, double width, double height, java.lang.String fileName)
          Creates a Lindenmayer system, evolves it for a number of steps, and outputs using turtle graphics, saving as an SVG file.
 java.lang.String getState()
          Gets the current state.
static void main(java.lang.String[] args)
          Tester.
 void nextStep()
          Performs one step of the evolution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lindenmayer

public Lindenmayer(java.lang.String axiom,
                   java.util.Map<java.lang.String,java.lang.String> rules)
Creates a new Lindenmayer system.

Parameters:
axiom - the initial state
rules - the replacement rules
Method Detail

getState

public java.lang.String getState()
Gets the current state.

Returns:
the current state

nextStep

public void nextStep()
Performs one step of the evolution.


evolveToString

public static java.lang.String evolveToString(java.lang.String axiom,
                                              java.util.Map<java.lang.String,java.lang.String> rules,
                                              int steps)
Creates a Lindenmayer system, evolves it for a number of steps, and outputs as a string.

Parameters:
axiom - the initial state of the system
rules - the rules for the system
steps - the number of steps to run

evolveToTG

public static void evolveToTG(java.lang.String axiom,
                              java.util.Map<java.lang.String,java.lang.String> rules,
                              int steps,
                              double angle,
                              double distance,
                              double x,
                              double y,
                              double dir,
                              double width,
                              double height,
                              java.lang.String fileName)
                       throws java.io.IOException
Creates a Lindenmayer system, evolves it for a number of steps, and outputs using turtle graphics, saving as an SVG file.

Parameters:
axiom - the initial state of the system
rules - the rules for the system
steps - the number of steps to run
angle - the angle to turn by
distance - the distance to move
x - the initial x-coordinate
y - the initial y-coordinate
dir - the initial direction
width - the width of the image
height - the height of the image
fileName - the filename to save under
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Tester. Set the first argument to "-s" for a sierpinksi triangle, or "-p" for a penrose tiling.

Parameters:
args - the arguments
Throws:
java.io.IOException