Koch curve: Difference between revisions
From JSXGraph Wiki
No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 30: | Line 30: | ||
<script language="JavaScript"> | <script language="JavaScript"> | ||
var brd = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 300, unitX: 1, unitY: 1}); | var brd = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 300, unitX: 1, unitY: 1}); | ||
var t = brd. | var t = brd.create('turtle'); | ||
function run() { | function run() { | ||
brd.suspendUpdate(); | brd.suspendUpdate(); | ||
Line 51: | Line 51: | ||
<source lang="javascript"> | <source lang="javascript"> | ||
var brd = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 300, unitX: 1, unitY: 1}); | var brd = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 300, unitX: 1, unitY: 1}); | ||
var t = brd. | var t = brd.create('turtle'); | ||
function run() { | function run() { | ||
brd.suspendUpdate(); | brd.suspendUpdate(); |
Revision as of 08:02, 22 July 2010
References
Source code
var brd = JXG.JSXGraph.initBoard('box', {originX: 300, originY: 300, unitX: 1, unitY: 1});
var t = brd.create('turtle');
function run() {
brd.suspendUpdate();
var code = document.getElementById('inputtext').value;
if (code=='') { return; }
eval(code);
brd.unsuspendUpdate();
}
function clearturtle() {
t.cs();
}
run();
function koch(x,level) {
if (level<1) {
t.fd(x);
} else {
koch(x/3,level-1);
t.lt(60);
koch(x/3,level-1);
t.rt(120);
koch(x/3,level-1);
t.lt(60);
koch(x/3,level-1);
}
}
t.cs();
t.hideTurtle();
t.setPos(-250,0);
t.rt(90);
koch(400,7);