Fern (fractal): Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 3: | Line 3: | ||
<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/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> | ||
Do 100 iterations: <form><input type='button' value=" | Do 100 iterations: <form><input type='button' value="OK" onClick="ifs();"></form> | ||
<div id="box" class="jxgbox" style="width:600px; height: | <div id="box" class="jxgbox" style="width:600px; height:500px;"></div> | ||
<script language="JavaScript"> | <script language="JavaScript"> | ||
board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 490, unitX: 5, unitY: 5}); | board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 490, unitX: 5, unitY: 5}); |
Revision as of 17:13, 28 November 2008
Do 100 iterations:
board = JXG.JSXGraph.initBoard('box', {originX: 250, originY: 490, unitX: 5, unitY: 5});
var p = board.createElement('point', [0,0], {style:10,labelcolor:'#FFFFFF00'});
function ifs() {
board.suspendUpdate();
for(var i=1; i<= 100; i++) {
var x = p.coords.usrCoords[1];
var y = p.coords.usrCoords[2];
var prob = Math.random();
if(prob < 0.85) {
p = board.createElement('point', [0.85*x+0.04*y+0,-0.04*x+0.85*y+10.6], {style:10,labelcolor:'#FFFFFF00'});
}
else if(prob >= 0.85 && prob < 0.92) {
p = board.createElement('point', [0.2*x-0.26*y+0,0.23*x+0.22*y+10.6], {style:10,labelcolor:'#FFFFFF00'});
}
else if(prob >= 0.92 && prob < 0.99) {
p = board.createElement('point', [-0.15*x+0.28*y+0,0.26*x+0.24*y+4.4], {style:10,labelcolor:'#FFFFFF00'});
}
else {
p = board.createElement('point', [0*x+0*y+0,0*x+0.16*y+0], {style:10,labelcolor:'#FFFFFF00'});
}
}
board.unsuspendUpdate();
}