docs: function(origin, direction) {
          var points = this.points,
              minDistance = Infinity;
          var d, d_nom, e, e_nom, denom;
  
          var originX = origin._x,
              directionX = direction.x,
              originY = origin._y,
              directionY = direction.y;
  
          var i = 0,
              l = points.length;
          var startX = points[l - 2],
              endX,
              edgeX,
              startY = points[l - 1],
              endY,
              edgeY;
          for (; i < l; i += 2) {
              endX = points[i];
              endY = points[i + 1];
              edgeX = endX - startX;
              edgeY = endY - startY;
  
              d_nom = (startX - originX) * edgeY - (startY - originY) * edgeX;
              e_nom =
                  (startX - originX) * directionY -
                  (startY - originY) * directionX;
              denom = directionX * edgeY - directionY * edgeX;
  
              if (denom !== 0) {
                  d = d_nom / denom;
                  e = e_nom / denom;
  
                  if (e >= 0 && e <= 1 && d >= 0 && d < minDistance)
                      minDistance = d;
              } else if (d_nom === 0 || e_nom === 0) {
                  d =
                      (startX - originX) * directionX +
                      (startY - originY) * directionY;
                  if (d >= 0 && d < minDistance) minDistance = d;
  
                  d =
                      (endX - originX) * directionX +
                      (endY - originY) * directionY;
                  if (d >= 0 && d < minDistance) minDistance = d;
              }
  
              startX = endX;
              startY = endY;
          }
  
          return minDistance;
      }