public class HalfEdge extends Object
EdgeGraph. HalfEdges link vertices whose locations are defined by
Coordinates. HalfEdges start at an
origin vertex, and terminate at a
destination vertex. HalfEdges always occur in symmetric pairs, with the
sym() method giving access to the oppositely-oriented component. HalfEdges and the methods on them form an edge algebra, which can be used to traverse and query the topology of the graph formed by the edges.
By design HalfEdges carry minimal information about the actual usage of the graph they represent. They can be subclassed to carry more information if required.
HalfEdges form a complete and consistent data structure by themselves, but an EdgeGraph is useful to allow retrieving edges by vertex and edge location, as well as ensuring edges are created and linked appropriately.
| Constructor and Description |
|---|
HalfEdge(Coordinate
Creates an edge originating from a given coordinate.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareAngularDirection(HalfEdge
Implements the total order relation:
|
int |
compareTo(Object
Compares edges which originate at the same vertex based on the angle they make at their origin vertex with the positive X-axis.
|
static HalfEdge |
create(Coordinate
Creates a HalfEdge pair representing an edge between two vertices located at coordinates p0 and p1.
|
int |
degree()
Computes the degree of the origin vertex.
|
double |
deltaX()
The X component of the distance between the orig and dest vertices.
|
double |
deltaY()
The Y component of the distance between the orig and dest vertices.
|
Coordinate |
dest()
Gets the destination coordinate of this edge.
|
boolean |
equals(Coordinate
Tests whether this edge has the given orig and dest vertices.
|
HalfEdge |
find(Coordinate
Finds the edge starting at the origin of this edge with the given dest vertex, if any.
|
protected void |
init(HalfEdge
|
static HalfEdge |
init(HalfEdge
Initialize a symmetric pair of halfedges.
|
void |
insert(HalfEdge
Inserts an edge into the ring of edges around the origin vertex of this edge.
|
HalfEdge |
next()
Gets the next edge CCW around the destination vertex of this edge.
|
HalfEdge |
oNext()
|
Coordinate |
orig()
Gets the origin coordinate of this edge.
|
HalfEdge |
prev()
Returns the edge previous to this one (with dest being the same as this orig).
|
HalfEdge |
prevNode()
Finds the first node previous to this edge, if any.
|
void |
setNext(HalfEdge
|
HalfEdge |
sym()
Gets the symmetric pair edge of this edge.
|
String |
toString()
Computes a string representation of a HalfEdge.
|
public HalfEdge(Coordinateorig)
orig - the origin coordinate
public static HalfEdgecreate(Coordinate p0, Coordinate p1)
p0 - a vertex coordinate
p1 - a vertex coordinate
public static HalfEdgeinit(HalfEdge e0, HalfEdge e1)
EdgeGraph subclasses. The edges are initialized to have each other as the
sym edge, and to have
next pointers which point to edge other. This effectively creates a graph containing a single edge.
e0 - a halfedge
e1 - a symmetric halfedge
protected void init(HalfEdgee)
public Coordinateorig()
public Coordinatedest()
public HalfEdgesym()
public HalfEdgenext()
public HalfEdgeprev()
public void setNext(HalfEdgee)
public HalfEdgeoNext()
public HalfEdgefind(Coordinate dest)
dest - the dest vertex to search for
public boolean equals(Coordinatep0, Coordinate p1)
p0 - the origin vertex to test
p1 - the destination vertex to test
public void insert(HalfEdgee)
e - the edge to insert
public int compareTo(Objectobj)
public int compareAngularDirection(HalfEdgee)
The angle of edge a is greater than the angle of edge b, where the angle of an edge is the angle made by the first segment of the edge with the positive x-axis
When applied to a list of edges originating at the same point, this produces a CCW ordering of the edges around the point.
Using the obvious algorithm of computing the angle is not robust, since the angle calculation is susceptible to roundoff error. A robust algorithm is:
CGAlgorithms.computeOrientation(Coordinate, Coordinate, Coordinate) function can be used to determine the relative orientation of the vectors. public double deltaX()
public double deltaY()
public StringtoString()
public int degree()
public HalfEdgeprevNode()