From "Turtle Geometry" by Harold Abelson, 1980
circle: POLY (variation)
Log in to post a comment.
const SIDE = 100; // min=1, max=100, step=1
const ANGLE = 108; // min=1, max=179, step=1
const MAX_ITER = 512;
const t = new Turtle();
// Center
const internal_angle = (180-ANGLE)/180*Math.PI;
const apothem = SIDE / 2 * Math.tan(internal_angle/2);
t.jump(-SIDE/2, -apothem);
const start = t.pos();
// The walk function will be called until it returns false.
function walk(i) {
t.forward(SIDE);
t.right(ANGLE);
return (i+1) < MAX_ITER && t.pos() !== start;
}