Euclid JS

Euclidean geometry in javascript.

This construction to trisect a line segment comes from Proofs Without Words by Scott Coble, via this page. The code looks like this:

      .point        ('A', width/7*3, height/3)
      .point        ('B', width/7*5, height/3)
      .segment      ('S', 'A', 'B')
      .circle       ('M', 'A', 'B')
      .circle       ('N', 'B', 'A')
      .intersection ('C', 'M', 'N', 0)
      .intersection ('D', 'M', 'N', 1)
      .line         ('T', 'A', 'C')
      .segment      ('U', 'A', 'D')
      .intersection ('E', 'T', 'M', scene.isnt('C'))
      .segment      ('V', 'E', 'B')
      .intersection ('F', 'V', 'U')
      .segment      ('W', 'F', 'C')
      .intersection ('W', 'S')
(The first argument in each case is a label. The third argument to intersection disambiguates if there could be multiple intersections.)