Lorenz XZ

Classic "butterfly" Lorenz attractor.

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);

// Global code will be evaluated once.
const turtle = new Turtle();
turtle.penup();

function project() {
    turtle.goto(x * 3, (-z + 28) * 3);
    // turtle.goto(x * 3, y * 3);
    // turtle.goto(y * 3, (-z + 28) * 3);
}

x = 1.0;
y = 1.0;
z = 1.0;
project();
turtle.pendown();

si = 10.0 ;
b = 8.0/3.0;
r = 28.0;

dt = .01;

// The walk function will be called until it returns false.
function walk(i) {
    nx = x + dt * (si * (y - x));
    ny = y + dt * (x * (r - z) - y);
    nz = z + dt * (x * y - b * z);
    x = nx;
    y = ny;
    z = nz;
    project();
    return i < 10000
}