implementation of the #gumowski-mira attractor

Log in to post a comment.

Canvas.setpenopacity(0.12); const turtle = new Turtle(); turtle.penup(); const a = -0.148; const b = 1; const scale = 3; const initialPosition = {x: 1, y: 11}; const iterations = 100000; let position = initialPosition; const positions = getPositions(iterations); function walk(i) { drawPoint(positions[i].x * scale,positions[i].y * scale); return i < positions.length -1; } function drawPoint(x, y) { turtle.goto(x,y); turtle.pendown(); turtle.forward(1) turtle.penup(); } function gumowskiMira(value) { const squared = value * value; return a * value + (2 * (1 - a) * squared) / (1 + squared); } function getPositions(amount) { const results = []; for (let i = 0; i < amount; i += 1) { const newX = b * position.y + gumowskiMira(position.x); const newY = -position.x + gumowskiMira(newX); const newPosition = { x: newX, y: newY }; results.push(newPosition); position = newPosition; } return results; }