Returns an interection of a list of polygons with the specified clip
polygon
351093
function(polygons, clipPolygon) {
        var result = [];
        for (var i = 0; i < polygons.length; i++) {
            var r = this.clipPolygon(polygons[i], clipPolygon);
            if (r && r.length) {
                result.push(r);
            }
        }
        return result;
    }
780249
def slots(self):
        """"""
        if self.implied:
            return ()

        data = clips.data.DataObject(self._env)

        lib.EnvDeftemplateSlotNames(self._env, self._tpl, data.byref)

        return tuple(
            TemplateSlot(self._env, self._tpl, n.encode()) for n in data.value)
236347
def get_polygons(self):
        

        status, data = self.http_client.get_json(
            POLYGONS_URI,
            params={'appid': self.API_key},
            headers={'Content-Type': 'application/json'})
        return [Polygon.from_dict(item) for item in data]
1120982
function polygonIntersectLine(x, y, basePoints, centerX, centerY, width, height, padding) {
  var intersections = [];
  var intersection;
  var transformedPoints = new Array(basePoints.length);
  var doTransform = true;

  if (width == null) {
    doTransform = false;
  }

  var points;

  if (doTransform) {
    for (var i = 0; i < transformedPoints.length / 2; i++) {
      transformedPoints[i * 2] = basePoints[i * 2] * width + centerX;
      transformedPoints[i * 2 + 1] = basePoints[i * 2 + 1] * height + centerY;
    }

    if (padding > 0) {
      var expandedLineSet = expandPolygon(transformedPoints, -padding);
      points = joinLines(expandedLineSet);
    } else {
      points = transformedPoints;
    }
  } else {
    points = basePoints;
  }

  var currentX, currentY, nextX, nextY;

  for (var _i2 = 0; _i2 < points.length / 2; _i2++) {
    currentX = points[_i2 * 2];
    currentY = points[_i2 * 2 + 1];

    if (_i2 < points.length / 2 - 1) {
      nextX = points[(_i2 + 1) * 2];
      nextY = points[(_i2 + 1) * 2 + 1];
    } else {
      nextX = points[0];
      nextY = points[1];
    }

    intersection = finiteLinesIntersect(x, y, centerX, centerY, currentX, currentY, nextX, nextY);

    if (intersection.length !== 0) {
      intersections.push(intersection[0], intersection[1]);
    }
  }

  return intersections;
}
675326
function getCrossings (points, edges, edgeBounds) {
  var result = []
  boxIntersect(edgeBounds, function (i, j) {
    var e = edges[i]
    var f = edges[j]
    if (e[0] === f[0] || e[0] === f[1] ||
      e[1] === f[0] || e[1] === f[1]) {
      return
    }
    var a = points[e[0]]
    var b = points[e[1]]
    var c = points[f[0]]
    var d = points[f[1]]
    if (segseg(a, b, c, d)) {
      result.push([i, j])
    }
  })
  return result
}
311945
public Optional<OffsetRange<OffsetType>> clipToBounds(OffsetRange<OffsetType> bounds) {
    if (bounds.contains(this)) {
      return Optional.of(this);
    }
    if (!bounds.overlaps(this)) {
      return Optional.absent();
    }
    final OffsetType newLowerBound;
    final OffsetType newUpperBound;
    if (bounds.startInclusive().asInt() > startInclusive().asInt()) {
      newLowerBound = bounds.startInclusive();
    } else {
      newLowerBound = startInclusive();
    }
    if (bounds.endInclusive().asInt() < endInclusive().asInt()) {
      newUpperBound = bounds.endInclusive();
    } else {
      newUpperBound = endInclusive();
    }
    return Optional.of(OffsetRange.fromInclusiveEndpoints(newLowerBound, newUpperBound));
  }
84322
def bounds(self):
        """"""
        corners = [self.image_corner(corner) for corner in self.corner_types()]
        return Polygon([[corner.x, corner.y] for corner in corners])
567354
function clipSegmentToLine(vOut, vIn, normal, offset, vertexIndexA) {
  // Start with no output points
  var numOut = 0;

  // Calculate the distance of end points to the line
  var distance0 = Vec2.dot(normal, vIn[0].v) - offset;
  var distance1 = Vec2.dot(normal, vIn[1].v) - offset;

  // If the points are behind the plane
  if (distance0 <= 0.0)
    vOut[numOut++].set(vIn[0]);
  if (distance1 <= 0.0)
    vOut[numOut++].set(vIn[1]);

  // If the points are on different sides of the plane
  if (distance0 * distance1 < 0.0) {
    // Find intersection point of edge and plane
    var interp = distance0 / (distance0 - distance1);
    vOut[numOut].v.setCombine(1 - interp, vIn[0].v, interp, vIn[1].v);

    // VertexA is hitting edgeB.
    vOut[numOut].id.cf.indexA = vertexIndexA;
    vOut[numOut].id.cf.indexB = vIn[0].id.cf.indexB;
    vOut[numOut].id.cf.typeA = Manifold.e_vertex;
    vOut[numOut].id.cf.typeB = Manifold.e_face;
    ++numOut;
  }

  return numOut;
}
1027190
private static Integer[] intersectedDocList(int[] facetDocList,
      Integer[] docSet) {
    if (facetDocList != null && docSet != null) {
      Integer[] c = new Integer[Math.min(facetDocList.length, docSet.length)];
      int ai = 0;
      int bi = 0;
      int ci = 0;
      while (ai < facetDocList.length && bi < docSet.length) {
        if (facetDocList[ai] < docSet[bi]) {
          ai++;
        } else if (facetDocList[ai] > docSet[bi]) {
          bi++;
        } else {
          if (ci == 0 || facetDocList[ai] != c[ci - 1]) {
            c[ci++] = facetDocList[ai];
          }
          ai++;
          bi++;
        }
      }
      return Arrays.copyOfRange(c, 0, ci);
    }
    return new Integer[] {};
  }
1234708
function earcutLinked (data, ear, triangles, dim, minX, minY, size, pass) {
  if (!ear) {
    return
  }

  // interlink polygon nodes in z-order
  if (!pass && minX !== undefined) {
    indexCurve(data, ear, minX, minY, size)
  }

  var stop = ear,
    prev, next

  // iterate through ears, slicing them one by one
  while (ear.prev !== ear.next) {
    prev = ear.prev
    next = ear.next

    if (isEar(data, ear, minX, minY, size)) {
      // cut off the triangle
      triangles.push(prev.i / dim)
      triangles.push(ear.i / dim)
      triangles.push(next.i / dim)

      // remove ear node
      next.prev = prev
      prev.next = next

      if (ear.prevZ) {
        ear.prevZ.nextZ = ear.nextZ
      }
      if (ear.nextZ) {
        ear.nextZ.prevZ = ear.prevZ
      }

      // skipping the next vertice leads to less sliver triangles
      ear = next.next
      stop = next.next

      continue
    }

    ear = next

    // if we looped through the whole remaining polygon and can't find any more ears
    if (ear === stop) {
      // try filtering points and slicing again
      if (!pass) {
        earcutLinked(data, filterPoints(data, ear), triangles, dim, minX, minY, size, 1)

        // if this didn't work, try curing all small self-intersections locally
      } else if (pass === 1) {
        ear = cureLocalIntersections(data, ear, triangles, dim)
        earcutLinked(data, ear, triangles, dim, minX, minY, size, 2)

        // as a last resort, try splitting the remaining polygon into two
      } else if (pass === 2) {
        splitEarcut(data, ear, triangles, dim, minX, minY, size)
      }

      break
    }
  }
}
1287293
function(subjectPolygon, clipPolygon) {
        var subj = subjectPolygon;
        if (!this.isClockwise(subj)) {
            subj = [].concat(subj).reverse();
        }
        var clip = clipPolygon;
        if (this.isClockwise(clip)) {
            clip = [].concat(clip).reverse();
        }
        var result = this._clipPolygon(subj, clip);
        return result;
    }
434255
def polygon_from_points(points):
    
    polygon = []
    for pair in points.split(" "):
        x_y = pair.split(",")
        polygon.append([float(x_y[0]), float(x_y[1])])
    return polygon
287888
def _intersected_edge(self, edges, cut_edge):
        
        for edge in edges:
            if self._edges_intersect(edge, cut_edge):
                return edge
185329
def clip( range = 0 .. 0xFF )
      if range.exclude_end?
        raise "Clipping does not support ranges with end value " +
              "excluded (such as #{range})"
      end
      collect { |x| x.major( range.begin ).minor range.end }
    end
1181095
function polygonCanSee2(polygon, a,b) {
    // for each edge
    for (var i = 0; i !== polygon.length; ++i) {
        // ignore incident edges
        if (i === a || i === b || (i + 1) % polygon.length === a || (i + 1) % polygon.length === b){
            continue;
        }
        if( lineSegmentsIntersect(polygonAt(polygon, a), polygonAt(polygon, b), polygonAt(polygon, i), polygonAt(polygon, i+1)) ){
            return false;
        }
    }
    return true;
}
794650
def _union_in_blocks(contours, block_size):
    

    n_contours = len(contours)
    for i in range(0, n_contours, block_size):
        j = min(i + block_size, n_contours)

        inners = []
        for c in contours[i:j]:
            p = _contour_to_poly(c)
            if p.type == 'Polygon':
                inners.append(p)
            elif p.type == 'MultiPolygon':
                inners.extend(p.geoms)
        holes = unary_union(inners)
        assert holes.is_valid

        yield holes
554539
def _sliced_list(self, selector):
        
        if self.skipmissing:
            return self.obj[selector]

        # TODO: can be optimized by observing list bounds
        keys = xrange(selector.start or 0,
                      selector.stop or sys.maxint,
                      selector.step or 1)
        res = []
        for key in keys:
            self._append(self.obj, key, res, skipmissing=False)
        return res