lorenz attractor

adapted from codepen.io/liabru/pen/eDktd

Log in to post a comment.

Canvas.setpenopacity(0.5);


var c = 28,
    h = 0.015,
    t = -6,
    x0 = 0, y0 = 1, z0 = 10,
    x1, y1, z1,
    cx = 0, cy = 0,
    sleepDuration = 3; //0; //1; //1.8;
    scale = 4.5; //10; //100; //150;

function sleep() {
    var date = new Date();
    var curDate = null;

    do {
        curDate = new Date();
    }
    while (curDate - date < sleepDuration);
}

const turtle = new Turtle();


function walk(i) {
    x1 = x0 + h * t * (x0 - y0);
    y1 = y0 + h * (-x0 * z0 + c * x0 - y0);
    z1 = z0 + h * (x0 * y0 - z0);
    // turtle.goto(cx + x0 * scale, cy + y0 * scale);
    turtle.goto(cx + x1 * scale, cy + y1 * scale);
    x0 = x1;
    y0 = y1;
    z0 = z1;
    sleep();
    return i < scale * 3000;
}