HalfEdge

class foronoi.graph.HalfEdge(incident_point, twin=None, origin=None)

Edges are normally treated as undirected and shared between faces. However, for some tasks (such as simplifying or cleaning geometry) it is useful to view faces as each having their own edges. You can think of this as splitting each shared undirected edge along its length into two half edges. (Boundary edges of course will only have one “half-edge”.) Each half-edge is directed (it has a start vertex and an end vertex).

The half-edge properties let you quickly find a half-edge’s source and destination vertex, the next half-edge, get the other half-edge from the same edge, find all half-edges sharing a given point, and other manipulations.

Examples

Get the half-edge’s source

>>> edge.origin

Get the half-edge’s destination

>>> edge.target # or edge.twin.origin

Get the previous and next half-edge

>>> edge.prev
>>> edge.next

Get the other half-edge from the same edge

>>> edge.twin

Find all half-edges sharing a given point

>>> edge.origin.connected_edges
Parameters
  • incident_point (Point) – The cell point of which this edge is the border

  • twin (HalfEdge) – The other half-edge from the same edge

  • origin (Breakpoint or Vertex) – The origin of the half edge. Can be a Breakpoint or a Vertex during construction, and only Vertex when the diagram is finished.

origin

Pointer to the origin. Can be breakpoint or vertex.

Type

Breakpoint or Vertex

next

Pointer to the next edge

Type

HalfEdge

prev

Pointer to the previous edge

Type

HalfEdge

delete()

Delete this half edge by pointing the previous edge to the next, and removing it from the origin’s connected edges list.

get_origin(y=None, max_y=None)

Get the coordinates of the edge’s origin. During construction of the Voronoi diagram, the origin can be a vertex, which has a fixed location, or a breakpoint, which is a breakpoint between two moving arcs. In the latter case, we need to calculate the position based on the y-coordinate of the sweep line.

Parameters
  • y (Decimal) – The y-coordinate of the sweep line.

  • max_y – Bounding box top for clipping infinitely highly positioned breakpoints.

Returns

origin

Return type

Coordinate

set_next(next)

Update the next-property for this edge and set the prev-property on the next-edge to the current edge.

Parameters

next (HalfEdge) – The next edge

property target

The twin’s origin.

Returns

vertex

Return type

Vertex

property twin

Get the other half-edge from the same edge

Returns

twin

Return type

HalfEdge