L-systems: Difference between revisions

From JSXGraph Wiki
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 12: Line 12:
<html>
<html>
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" />
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/prototype.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<form><textarea id="inputtext0" rows=15 cols=35 wrap="off" style="width:600px;">
<form><textarea id="inputtext0" rows=15 cols=35 wrap="off" style="width:600px;">
Line 38: Line 37:
<input type="button" value="clear" onClick="clearturtle(0)">
<input type="button" value="clear" onClick="clearturtle(0)">
</form>
</form>
<div id="box0" class="jxgbox" style="width:600px; height:600px;"></div>
</html>
<script language="JavaScript">
<jsxgraph width="600" height="600" box="box0">
var t;
var t;
var turtle = [];
var turtle = [];
var brd = [];
var brd = [];
brd[0] = JXG.JSXGraph.initBoard('box0', {originX: 300, originY: 300, unitX: 1, unitY: 1});
brd[0] = JXG.JSXGraph.initBoard('box0', {boundingbox: [-300, 300, 300, -300]});
turtle[0] = brd[0].createElement('turtle');
turtle[0] = brd[0].create('turtle');


function expander(level,axiom,rules) {
function expander(level,axiom,rules) {
Line 107: Line 106:
function run(nr) {
function run(nr) {
   brd[nr].suspendUpdate();
   brd[nr].suspendUpdate();
   var code = $('inputtext'+nr).value;
   var code = document.getElementById('inputtext'+nr).value;
   if (code=='') { return; }
   if (code=='') { return; }
   t = turtle[nr];
   t = turtle[nr];
Line 121: Line 120:
   turtle[nr].cs();
   turtle[nr].cs();
}
}
</script>
</jsxgraph>
</html>


====More examples====
====More examples====

Latest revision as of 07:59, 8 June 2011

Online experiments with Lindenmayer Systems

A Lindenmayer System consists of

  • an initial string called axiom
  • a set of rewriting rules

This is an experimental page, where the Lindenmayer Systems can be changed online. The visualization is done by the JavaScript library JSXGraph. For each system a maximum level is defined. If this value is increased, the complexity of the drawing rises and running time increases, too.

Examples

Most of the examples are from the book by Przemyslaw Prusinkiewicz and James Hanan: Lindenmayer Systems, Fractals, and Plants, see the References.

First Example: Sierpinski curve


More examples

The underlying JavaScript code

The underlying JavaScript code for producing Lindenmayer systems

References