docs: function intersection (a1, a2, b1, b2, noEndpointTouch) {
      // The algorithm expects our lines in the form P + sd, where P is a point,
      // s is on the interval [0, 1], and d is a vector.
      // We are passed two points. P can be the first point of each pair. The
      // vector, then, could be thought of as the distance (in x and y components)
      // from the first point to the second point.
      // So first, let's make our vectors:
      var va = [a2[0] - a1[0], a2[1] - a1[1]];
      var vb = [b2[0] - b1[0], b2[1] - b1[1]];
      // We also define a function to convert back to regular point form:
  
      /* eslint-disable arrow-body-style */
  
      function toPoint(p, s, d) {
        return [
          p[0] + s * d[0],
          p[1] + s * d[1]
        ];
      }
  
      /* eslint-enable arrow-body-style */
  
      // The rest is pretty much a straight port of the algorithm.
      var e = [b1[0] - a1[0], b1[1] - a1[1]];
      var kross    = crossProduct(va, vb);
      var sqrKross = kross * kross;
      var sqrLenA  = dotProduct(va, va);
      //const sqrLenB  = dotProduct(vb, vb);
  
      // Check for line intersection. This works because of the properties of the
      // cross product -- specifically, two vectors are parallel if and only if the
      // cross product is the 0 vector. The full calculation involves relative error
      // to account for possible very small line segments. See Schneider & Eberly
      // for details.
      if (sqrKross > 0/* EPS * sqrLenB * sqLenA */) {
        // If they're not parallel, then (because these are line segments) they
        // still might not actually intersect. This code checks that the
        // intersection point of the lines is actually on both line segments.
        var s = crossProduct(e, vb) / kross;
        if (s < 0 || s > 1) {
          // not on line segment a
          return null;
        }
        var t = crossProduct(e, va) / kross;
        if (t < 0 || t > 1) {
          // not on line segment b
          return null;
        }
        if (s === 0 || s === 1) {
          // on an endpoint of line segment a
          return noEndpointTouch ? null : [toPoint(a1, s, va)];
        }
        if (t === 0 || t === 1) {
          // on an endpoint of line segment b
          return noEndpointTouch ? null : [toPoint(b1, t, vb)];
        }
        return [toPoint(a1, s, va)];
      }
  
      // If we've reached this point, then the lines are either parallel or the
      // same, but the segments could overlap partially or fully, or not at all.
      // So we need to find the overlap, if any. To do that, we can use e, which is
      // the (vector) difference between the two initial points. If this is parallel
      // with the line itself, then the two lines are the same line, and there will
      // be overlap.
      //const sqrLenE = dotProduct(e, e);
      kross = crossProduct(e, va);
      sqrKross = kross * kross;
  
      if (sqrKross > 0 /* EPS * sqLenB * sqLenE */) {
      // Lines are just parallel, not the same. No overlap.
        return null;
      }
  
      var sa = dotProduct(va, e) / sqrLenA;
      var sb = sa + dotProduct(va, vb) / sqrLenA;
      var smin = Math.min(sa, sb);
      var smax = Math.max(sa, sb);
  
      // this is, essentially, the FindIntersection acting on floats from
      // Schneider & Eberly, just inlined into this function.
      if (smin <= 1 && smax >= 0) {
  
        // overlap on an end point
        if (smin === 1) {
          return noEndpointTouch ? null : [toPoint(a1, smin > 0 ? smin : 0, va)];
        }
  
        if (smax === 0) {
          return noEndpointTouch ? null : [toPoint(a1, smax < 1 ? smax : 1, va)];
        }
  
        if (noEndpointTouch && smin === 0 && smax === 1) { return null; }
  
        // There's overlap on a segment -- two points of intersection. Return both.
        return [
          toPoint(a1, smin > 0 ? smin : 0, va),
          toPoint(a1, smax < 1 ? smax : 1, va)
        ];
      }
  
      return null;
    }