Not all combinations are valid.
2 < 2q < p
gcd(p, q) = 1
Log in to post a comment.
// https://en.wikipedia.org/wiki/Regular_polygon#Regular_star_polygons // https://mathworld.wolfram.com/StarPolygon.html Canvas.setpenopacity(1); // 2 < 2q < p, gcd(p, q) = 1 // how many points const p = 7; // min=5, max=30, step=1 // how many points to skip when connectingh const q = 2; // min=2, max=15, step=1 const radius = 100; // min=10, max=100, step=10 const sides = p; const angle = 360 * q / p; // Global code will be evaluated once. const turtle = new Turtle(); // center horizontally turtle.penup(); turtle.goto(0, -radius); turtle.right(angle/2); turtle.pendown(); const length = radius*Math.sin(2*q/p*Math.PI)/Math.sin((p-2*q)/(2*p)*Math.PI); // The walk function will be called until it returns false. function walk(i) { turtle.forward(length); turtle.right(angle); return i < sides; }