Koch curve: Difference between revisions

From JSXGraph Wiki
No edit summary
No edit summary
Line 29: Line 29:
<input type="button" value="clear" onClick="clearturtle()">
<input type="button" value="clear" onClick="clearturtle()">
</form>
</form>
</html>
===Output===
<html>
<div id="box" class="jxgbox" style="width:600px; height:600px;"></div>
<div id="box" class="jxgbox" style="width:600px; height:600px;"></div>
<script language="JavaScript">
<script language="JavaScript">
Line 48: Line 51:


===References===
===References===
* [http://www.mathcurve.com/fractals/koch/koch.shtml http://www.mathcurve.com/fractals/koch/koch.shtml]
This example is from
* [http://de.wikipedia.org/wiki/Logo_(Programmiersprache) http://de.wikipedia.org/wiki/Logo_(Programmiersprache)]


===Source code===
===Source code===
<source lang="javascript">
<source lang="javascript">
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);
</source>
</source>
[[Category:Examples]]
[[Category:Examples]]
[[Category:Turtle Graphics]]
[[Category:Turtle Graphics]]
[[Category:Fractals]]
[[Category:Fractals]]

Revision as of 15:03, 21 December 2008


Output

References

This example is from

Source code