Chords

Draw n Chords
Allows changing the angle at the cost of increased pen up distance

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);
// https://www.varsitytutors.com/intermediate_geometry-help/how-to-find-the-length-of-a-chord
// Chord length using perpendicular distance from the center = 2 × √(r2 − d2). 
// https://www.cuemath.com/geometry/Chords-of-a-circle/
// Released under the MIT licence 
// https://mit-license.org/
// you can use this for commercial gain if you like eg you can sell artworks with this image.

const numLines=200; // min=0 max=210 step=1 
const angle=0; // min=0 max=360 step=1
const gap=1; // min=0.5 max=3 step=0.1
const radius=95; // min=10 max=99 step=1
const turtle = new Turtle();

let r2 = radius * radius;
let chordLength;
    
for(let n=-numLines/2; n < numLines; n = n + gap){
  d = n -1;
  d2 = d * d;
  chordLength = 2 * Math.sqrt(r2 - d2);
  turtle.jump(0, + n);

  turtle.seth(angle);
  turtle.penup();
  turtle.forward(chordLength /2);
  turtle.pendown();
  turtle.back(chordLength);
}