geom2d.voronoiclip

Voronoi graph clipping.

geom2d.voronoiclip.clip_voronoi_segments(diagram: VoronoiDiagram, clip_rect: Box) list[Line]

Clip a voronoi diagram to a clipping rectangle.

Parameters:
  • diagram – A VoronoiDiagram.

  • clip_rect – Clipping rectangle.

Returns:

A list of (possibly) clipped voronoi segments.

geom2d.voronoiclip.clip_voronoi_segments_poly(voronoi_segments: Iterable[TLine], clip_polygon: Sequence[TPoint]) list[Line]

Clip voronoi segments to a polygon.

Parameters:
  • voronoi_segments – List of Voronoi segments.

  • clip_polygon – Clipping polygon.

geom2d.voronoiclip.clipped_delaunay_segments(voronoi_diagram: VoronoiDiagram, clip_polygon: Sequence[TPoint]) list[Line]

Get clipped Delauney segments.

geom2d.voronoiclip.line_inside_hull(points: Sequence[TPoint], line: TLine, allow_hull: bool = False) bool

Test if line is inside or on the polygon defined by points.

This is a special case…. basically the line segment will lie on the hull, have one endpoint on the hull, or lie completely within the hull, or be completely outside the hull. It will not intersect. This works for the Delaunay triangles and polygon segments…

Parameters:
  • points – polygon vertices. A list of 2-tuple (x, y) points.

  • line – line segment to test.

  • allow_hull – allow line segment to lie on hull

Returns:

True if line is inside or on the polygon defined by points. Otherwise False.