Fork: Lorenz XZ

Classic "butterfly" Lorenz attractor.
I just added a slider, when I plotted the original 10,000 iterations was too many.

Log in to post a comment.

// Forked from "Lorenz XZ" by evilotto
// https://turtletoy.net/turtle/30f29b215b

// 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();
const n = 2000; //min=300 max=10000 step=100
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 < n
}