edu.gwu.geometry
Class Geometry

java.lang.Object
  |
  +--edu.gwu.geometry.Geometry

public class Geometry
extends java.lang.Object

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

Geometry

public Geometry()
Method Detail

between

public 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.
Parameters:
a - a Pointd value
b - a Pointd value
c - a Pointd value
Returns:
a boolean value

collinear

public static boolean collinear(Pointd a,
                                Pointd b,
                                Pointd c)
Method collinear tells you if three given points are collinear.
Parameters:
a - a Pointd value
b - a Pointd value
c - a Pointd value
Returns:
a boolean value

segSegInt

public 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. 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.
Parameters:
a - a Pointd value
b - a Pointd value
c - a Pointd value
d - a Pointd value
Returns:
an IntersectionInfo value

segSegInt

public static IntersectionInfo segSegInt(LineSegment L1,
                                         LineSegment L2)
Method segSegInt takes two line-segments and and finds an intersection point, if any. This method calls the more generic one using points.
Parameters:
L1 - a LineSegment value
L2 - a LineSegment value
Returns:
an IntersectionInfo value

properIntersection

public static Pointd properIntersection(LineSegment L1,
                                        LineSegment L2)
Method 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.
Parameters:
L1 - a LineSegment value
L2 - a LineSegment value
Returns:
a Pointd value

parallelInt

public static IntersectionInfo parallelInt(Pointd a,
                                           Pointd b,
                                           Pointd c,
                                           Pointd d)
Method parallelInt is for collinear segments, and is not typically used by algorithms.
Parameters:
a - a Pointd value
b - a Pointd value
c - a Pointd value
d - a Pointd value
Returns:
an IntersectionInfo value