A Fake Circle made of Straight Lines

Inspired by this post on Reddit, I wrote this little script to do the same thing. The circle is an illusion created by 100 straight-line tangents to an invisible circle. The tangents are created by drawing a chord in a larger concentric circle, and moving it’s endpoints around by equal increments 100 times. The larger circle’s circumference is defined by x=sin(t), y=cos(t), for t in the range 0 to 2*pi. So a chord’s endpoints will be defined by 2 different values of t.

  • Import turtle & math libraries
  • Set r (radius) to 400 px.
  • Set angular increment to a 100th of the circle, i.e. 2*pi/100
  • Initialise the plotting angle to to 0, and an offset to something in the range 0:2*pi
  • Make 100 steps around the circle
    • compute endpoints (x1,y1), (x2,y2) of a chord
    • lift pen and goto first endpoint; drop it & goto second
    • increment angle

[welcomewikilite wikiurl=”https://en.wikipedia.org/wiki/Pi” sections=”Polygon approximation era” settings=””]