Fractal Polygons: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
In the last line of the input window there is the command | |||
<source lang="javascript"> | |||
fracPolygone(5,100,0.4,5,1); | |||
</source> | |||
The meaning of the parameters is | |||
* 5: number of vertices of the regular polygone, | |||
* 100: length of a side of the initial poylgone, | |||
* 0.4: shrink factor from one level to the next, | |||
* 5: number of recursion steps | |||
* 1 | |||
<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" /> | ||
Line 5: | Line 16: | ||
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxturtle.js"></script> | <script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxturtle.js"></script> | ||
<form><textarea id="inputtext" rows=3 cols=35 wrap="off" style="width:600px;"> | <form><textarea id="inputtext" rows=3 cols=35 wrap="off" style="width:600px;"> | ||
function fracPolygone(corner,len,shrink,recurs | function fracPolygone(corner,len,shrink,recurs) { | ||
if (recurs>0) { | if (recurs>0) { | ||
if ( | if (argument.length==4) { // initial call | ||
t.rt(180); | t.rt(180); | ||
fracPolygone(corner,len*shrink,shrink,recurs-1, | fracPolygone(corner,len*shrink,shrink,recurs-1,1); | ||
t.lt(180); | t.lt(180); | ||
} | } | ||
Line 17: | Line 27: | ||
for(var i=0;i<corner-1;i++) { | for(var i=0;i<corner-1;i++) { | ||
t.rt(180); | t.rt(180); | ||
fracPolygone(corner,len*shrink,shrink,recurs-1, | fracPolygone(corner,len*shrink,shrink,recurs-1,1); | ||
t.lt(180); | t.lt(180); | ||
t.fd(len); | t.fd(len); | ||
Line 28: | Line 38: | ||
t.setPos(-100,0); | t.setPos(-100,0); | ||
t.setPenColor('blue'); | t.setPenColor('blue'); | ||
fracPolygone(5,100,0.4, | fracPolygone(5,100,0.4,5); | ||
</textarea><br /> | </textarea><br /> | ||
<input type="button" value="run" onClick="run()"> | <input type="button" value="run" onClick="run()"> |
Revision as of 11:16, 21 December 2008
In the last line of the input window there is the command
fracPolygone(5,100,0.4,5,1);
The meaning of the parameters is
- 5: number of vertices of the regular polygone,
- 100: length of a side of the initial poylgone,
- 0.4: shrink factor from one level to the next,
- 5: number of recursion steps
- 1
References
- Peter Baptist, Wolfgang Neidhardt, Alfred Wassermann: Symmetry and Regular Polygons, Prispevki k poucevanju Matematike, The Improvement of Mathematics Education in Secondary Schools: A Tempus Project, Maribor 1996