java.lang.Object | +--edu.gwu.geometry.Geometry
Class Geometry
provides a library of useful methods in
computational geometry. All the methods are static, much like java.lang.Math
.
The methods allow exact or inexact comparisons: since geometric data typically has
real values geometric computations are subject to arithmetic round-off errors.
Using inexact comparisons (the default) is usually safer.
Constructor Summary | |
Geometry()
|
Method Summary | |
static boolean |
between(Pointd a,
Pointd b,
Pointd c)
Method between tells you if point c is on the line segment
joining points a and b. |
static boolean |
collinear(Pointd a,
Pointd b,
Pointd c)
Method collinear tells you if three given points
are collinear. |
static IntersectionInfo |
parallelInt(Pointd a,
Pointd b,
Pointd c,
Pointd d)
Method parallelInt is for collinear segments, and is not typically
used by algorithms. |
static Pointd |
properIntersection(LineSegment L1,
LineSegment L2)
Method properIntersection returns an intersection point
if a proper intersection occurred. |
static IntersectionInfo |
segSegInt(LineSegment L1,
LineSegment L2)
Method segSegInt takes two line-segments and
and finds an intersection point, if any. |
static IntersectionInfo |
segSegInt(Pointd a,
Pointd b,
Pointd c,
Pointd d)
Method segSegInt finds the point of intersection p between two
segments ab and cd. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Geometry()
Method Detail |
public static boolean between(Pointd a, Pointd b, Pointd c)
between
tells you if point c is on the line
segment joining points a and b.a
- a Pointd
valueb
- a Pointd
valuec
- a Pointd
valueboolean
valuepublic static boolean collinear(Pointd a, Pointd b, Pointd c)
collinear
tells you if three given points
are collinear.a
- a Pointd
valueb
- a Pointd
valuec
- a Pointd
valueboolean
valuepublic static IntersectionInfo segSegInt(Pointd a, Pointd b, Pointd c, Pointd d)
segSegInt
finds the point of intersection p between two
segments ab and cd. Returns the point p and an integer code in an instance
of IntersectionInfo
with the following meaning:
'10+': The segments collinearly overlap, sharing a point.
'2': An endpoint (vertex) of one segment is on the other segment,
but 'e' doesn't hold.
'1': The segments intersect properly (i.e., they share a point and
neither 'v' nor 'e' holds).
'0': The segments do not intersect (i.e., they share no points).
Note that two collinear segments that share just one point, an endpoint
of each, returns '10+' rather than '2' as one might expect.a
- a Pointd
valueb
- a Pointd
valuec
- a Pointd
valued
- a Pointd
valueIntersectionInfo
valuepublic static IntersectionInfo segSegInt(LineSegment L1, LineSegment L2)
segSegInt
takes two line-segments and
and finds an intersection point, if any. This method calls
the more generic one using points.L1
- a LineSegment
valueL2
- a LineSegment
valueIntersectionInfo
valuepublic static Pointd properIntersection(LineSegment L1, LineSegment L2)
properIntersection
returns an intersection point
if a proper intersection occurred. Most line-segment intersection algorithms
will want to use this method to report proper intersections. A proper intersection
is when the line segments are not collinear and when one of the following
two cases occur: (1) no endpoint of one segment lies in the other
segment (thus, they cleanly intersect); (2) an endpoint of one segment may lie on the
other segment. The method returns null
otherwise.L1
- a LineSegment
valueL2
- a LineSegment
valuePointd
valuepublic static IntersectionInfo parallelInt(Pointd a, Pointd b, Pointd c, Pointd d)
parallelInt
is for collinear segments, and is not typically
used by algorithms.a
- a Pointd
valueb
- a Pointd
valuec
- a Pointd
valued
- a Pointd
valueIntersectionInfo
value