Difference between revisions of "Koch curve"

From JSXGraph Wiki
Jump to navigationJump to search
Line 48: Line 48:
  
 
===References===
 
===References===
This example is from
 
 
* [http://www.mathcurve.com/fractals/koch/koch.shtml http://www.mathcurve.com/fractals/koch/koch.shtml]
 
* [http://www.mathcurve.com/fractals/koch/koch.shtml http://www.mathcurve.com/fractals/koch/koch.shtml]
  

Revision as of 17:02, 21 December 2008


References

Source code

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);