LSystem Plot - Maple Help

Fractals[LSystem]

 LSystemPlot
 Lindenmayer System Plot Generator

 Calling Sequence LSystemPlot(state, constants) LSystemPlot(state, constants, opts)

Parameters

 state - string or Vector(integer) ; specifies the state of the LSystem, which is translated to a plot using constants constants - list(character=string) or list(integer=string) ; a list characters or integers, with the corresponding plotting actions opts - (optional) keyword options of the form opt=value where opt and value are described below

Options

 • initialangle: keyword option of the form initialangle=value where value is a floating-point or integer number, which is the initial angle that the LSystem begins to plot with, when the LSystem is two dimensional. The default value is 0.
 • xinitialangle: keyword option of the form xinitialangle=value where value is a floating-point or integer number, which is the initial x-axis angle that the LSystem begins to plot with, when the LSystem is three dimensional. The default value is 0.
 • yinitialangle: keyword option of the form yinitialangle=value where value is a floating-point or integer number, which is the initial y-axis angle that the LSystem begins to plot with, when the LSystem is three dimensional. The default value is 0.
 • dimension : keyword option of the form dimension=2 or dimension=3, which determines the dimension of the plot. If no value is given then the dimension of the plot will be determined by constants.
 • All additional options are interpreted as plotting options.

Description

 • The LSystemPlot command takes a state and reads through it in sequential order and uses the plotting actions defined in constants to translate each element in the state to a plotting action. These plotting actions are used to construct the plot of the LSystem. LSystem[Iterate] can be used to apply iterations to states, to create new states.
 • The state parameter is a sequence of characters. It can be input as string, or as Vector of integers in the range [1,255], whose values correspond to the ASCII values of the characters of the sequence.
 • The constants parameter of the LSystem is comprised of sequences of commands that are listed later. They can be input as a list(character=string), where the string is a sequence of plotting commands. When the state is read, each character or character corresponding to an ASCII value will cause the plotting commands corresponding to that character to be performed. The constants parameter can also be input as list(integer=string), where the string is once again a sequence of plotting commands. When the state is read, each ASCII value or ASCII value corresponding to a character value will cause the plotting commands corresponding to that ASCII value to be performed. For either input, if a character or ASCII value does not have a corresponding sequence of plotting commands in constants, it is assumed to perform no plotting commands.
 • LSystemPlot returns a plot of the LSystem state, with any plotting options used. The plot has no axes, black lines, and constrained scaling by default.
 • Plotting actions are of the form "command1:arg1;command2:arg2;...;commandN:argN;"

Available 2-D commands:

 – draw:n : Draws a line at the current angle of length n. n can be of type float or integer.
 – turn:n : Turns the current angle n degrees. n can be of type float or integer.
 – push:position or push:angle : pushes the current position or angle onto a stack. NOTE:position and angle are literal parts of the string and are not variables.
 – pop:position or pop:angle : pops the most recently pushed position or angle off the stack and sets it to the current position or angle.

Available 3-D commands:

 – draw:n : Draws a line at the current angle of length n. n can be of type float or integer.
 – turnx:n : Turns the current angle n degrees in the x-axis. n can be of type float or integer.
 – turny:n : Turns the current angle n degrees in the y-axis. n can be of type float or integer.
 – push:position or push:angle : pushes the current position or angle onto a stack. NOTE:position and angle are literal parts of the string and are not variables.
 – pop:position or pop:angle : pops the most recently pushed position or angle off the stack and sets it to the current position or angle.

Examples

 > $\mathrm{with}\left(\mathrm{Fractals}:-\mathrm{LSystem}\right):$
 > $\mathrm{state}≔"F+F+F+F"$
 ${\mathrm{state}}{≔}{"F+F+F+F"}$ (1)
 > $\mathrm{cons}≔\left["F"="draw:1","+"="turn:-90"\right]$
 ${\mathrm{cons}}{≔}\left[{"F"}{=}{"draw:1"}{,}{"+"}{=}{"turn:-90"}\right]$ (2)
 > $\mathrm{LSystemPlot}\left(\mathrm{state},\mathrm{cons}\right)$
 > $\mathrm{rules}≔\left["F"="FF+F++F+F"\right]$
 ${\mathrm{rules}}{≔}\left[{"F"}{=}{"FF+F++F+F"}\right]$ (3)
 > $\mathrm{newstate1}≔\mathrm{Iterate}\left(\mathrm{state},\mathrm{rules}\right)$
 ${\mathrm{newstate1}}{≔}{"FF+F++F+F+FF+F++F+F+FF+F++F+F+FF+F++F+F"}$ (4)
 > $\mathrm{LSystemPlot}\left(\mathrm{newstate1},\mathrm{cons}\right)$
 > $\mathrm{newstate2}≔\mathrm{Iterate}\left(\mathrm{newstate1},\mathrm{rules}\right)$
 ${\mathrm{newstate2}}{≔}{"FF+F++F+FFF+F++F+F+FF+F++F+F++FF+F++F+F+FF+F++F+F+FF+F++F+FFF+F++F+F+FF+F++F+F++FF+F++F+F+FF+F++F+F+FF+F++F+FFF+F++F+F+FF+F++F+F++FF+F++F+F+FF+F++F+F+FF+F++F+FFF+F++F+F+FF+F++F+F++FF+F++F+F+FF+F++F+F"}$ (5)
 > $\mathrm{LSystemPlot}\left(\mathrm{newstate2},\mathrm{cons}\right)$
 > $\mathrm{state}≔"0"$
 ${\mathrm{state}}{≔}{"0"}$ (6)
 > $\mathrm{cons}≔\left["0"="draw:0.5","1"="draw:1","\left["="push:position;push:angle;turn:35","\right]"="pop:position;pop:angle;turn:-35"\right]$
 ${\mathrm{cons}}{≔}\left[{"0"}{=}{"draw:0.5"}{,}{"1"}{=}{"draw:1"}{,}{"\left["}{=}{"push:position;push:angle;turn:35"}{,}{"\right]"}{=}{"pop:position;pop:angle;turn:-35"}\right]$ (7)
 > $\mathrm{LSystemPlot}\left(\mathrm{state},\mathrm{cons}\right)$
 > $\mathrm{rules}≔\left["1"="11","0"="1\left[0\right]0"\right]$
 ${\mathrm{rules}}{≔}\left[{"1"}{=}{"11"}{,}{"0"}{=}{"1\left[0\right]0"}\right]$ (8)
 > $\mathrm{newstate1}≔\mathrm{Iterate}\left(\mathrm{state},\mathrm{rules}\right)$
 ${\mathrm{newstate1}}{≔}{"1\left[0\right]0"}$ (9)
 > $\mathrm{LSystemPlot}\left(\mathrm{newstate1},\mathrm{cons}\right)$
 > $\mathrm{newstate2}≔\mathrm{Iterate}\left(\mathrm{newstate1},\mathrm{rules}\right)$
 ${\mathrm{newstate2}}{≔}{"11\left[1\left[0\right]0\right]1\left[0\right]0"}$ (10)
 > $\mathrm{LSystemPlot}\left(\mathrm{newstate2},\mathrm{cons}\right)$

Compatibility

 • The Fractals:-LSystem:-LSystemPlot command was introduced in Maple 2015.