|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hermit.geometry.Edge
public class Edge
An immutable edge in a geometric graph.
This immutable class embodies an edge in a graph where the vertices are assumed to be points in the plane. Either or both of the vertices may be at infinity, in which case this class can provide the position and direction of the line representing the edge.
Constructor Summary | |
---|---|
Edge(Point a,
Point b)
Create an Edge from individual vertices. |
|
Edge(Point a,
Point b,
Point ld,
Point rd)
Create an Edge from two data points and individual vertices. |
Method Summary | |
---|---|
int |
compareTo(Edge ev)
Compare an edge against another edge. |
Vector |
directionVector()
Get the direction vector for this edge. |
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one. |
Point |
getDatumA()
Get one datum point of this edge (denoted "A"). |
Point |
getDatumB()
Get one datum point of this edge (denoted "B"). |
Point |
getVertexA()
Get one vertex of this edge (denoted "A"). |
Point |
getVertexB()
Get one vertex of this edge (denoted "B"). |
int |
hashCode()
Returns a hash code value for the object. |
boolean |
isInfinite()
Determine whether this edge is infinite. |
boolean |
isPartlyInfinite()
Determine whether this edge is partly infinite. |
double |
length()
Get the length of this edge. |
Point |
referencePoint()
Get a reference point which fixes the position of this edge. |
java.lang.String |
toString()
Convert this instance to a String suitable for display. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Edge(Point a, Point b)
a
- One vertex, in no particular order. Must be
a real Point.b
- The other vertex. Must be a real Point.public Edge(Point a, Point b, Point ld, Point rd)
ld
- One data point for the edge. This is a point
which the edge passes through, and defines
the position and direction of an infinite edge.rd
- Other data point for the edge.a
- One vertex, in no particular order. Must be
Point.INFINITE or a real Point.b
- The other vertex. May be
Point.INFINITE or a real Point.Method Detail |
---|
public Point getVertexA()
public Point getVertexB()
public Point getDatumA()
public Point getDatumB()
public boolean isInfinite()
public boolean isPartlyInfinite()
public Point referencePoint()
public Vector directionVector()
public double length()
public boolean equals(java.lang.Object obj)
This method simply compares the co-ordinates of the two points, with a limited precision.
This comparison has little objective value; it is used to enforce a natural ordering on edges, so that arrays of edges can be compared easily for equality. This is in turn used for testing. Because compareTo() only compares vertices, so does this method.
Note that the precision of the test is limited by the precision
set in MathTools.setPrecision(double)
. That is, only as
many fractional digits are compared as configured there; hence,
two very close points will be considered equal.
equals
in class java.lang.Object
obj
- The reference object with which to compare.
public int compareTo(Edge ev)
Point.compareTo(Point)
.
Note that the precision of the test is limited by the precision
set in MathTools.setPrecision(double)
. That is, only as
many fractional digits are compared as configured there; hence,
two very close points will be considered equal.
This comparison has little objective value; it is used to enforce a natural ordering on edges, so that arrays of edges can be compared easily for equality. This is in turn used for testing.
compareTo
in interface java.lang.Comparable<Edge>
ev
- The other edge to compare to.
public int hashCode()
The hash code returned here is based on the hash codes of
the vertices. See Point.hashCode()
. This means that
the least significant bits of the co-ordinates are not compared,
in line with the precision set in
MathTools.setPrecision(double)
. Hence, this method should
be consistent with equals() and compareTo().
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |