en.wikipedia.org/wiki/hypotrochoid

Partially inspired by this Turtle:

Spirographs

It's easy for the sliders to careen into large drawings that will lag your computer. So be a little careful.

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(); const radius_1 = 17; // min = 2 max = 20 step = 0.01 const radius_2 = 14; // min = 2 max = 20 step = 0.01 const radius_1_delta = 75; // min = 20 max = 200 step = .1 const radius_2_delta = 69; // min = 20 max = 200 step = .1 const focus = 7; // min = 0.5 max = 20 step = 0.01 const scale = .5; // min = .1 max = 5 step = .01 const gap = 12; // min = 5 max = 30 step = 1 let grid_size = 13; // min = 1 max = 20 step = 1 const steps = 2000; // min = 1 max = 3000 step = 1 grid_size = grid_size - 1; // shhhh I'm too lazy to figure out how to actually fix this function draw_hypotrochoid(x, y, a, b, h) { turtle.penup(); let t = 0; let turtle_x = x + (a - b) * Math.cos(t) + h * Math.cos(t * (a/b - 1)); let turtle_y = y + (a - b) * Math.sin(t) + h * Math.sin(t * (a/b - 1)); turtle.goto(turtle_x, turtle_y); turtle.pendown(); for(let i = 0; i < steps; i++) { t = i / 50 turtle_x = x + (a - b) * Math.cos(t) + h * Math.cos(t * (a/b - 1)); turtle_y = y + (a - b) * Math.sin(t) + h * Math.sin(t * (a/b - 1)); turtle.goto(turtle_x, turtle_y); } } for(let i = -gap * grid_size / 2 ; i <= gap * grid_size / 2 ; i+= gap) { for(let j = -gap * grid_size / 2 ; j <= gap * grid_size / 2 ; j+= gap) { draw_hypotrochoid(i,j,(i / radius_1_delta + radius_1) * scale,(j / radius_2_delta + radius_2) * scale, focus * scale) } }