Specifies and implements various fundamental Computational Geometric algorithms. The algorithms supplied in this class are robust for double-precision floating point.
Tests whether a point lies inside or on a ring. The ring may be oriented in either direction. A point lying exactly on the ring boundary is considered to be inside the ring.
This method does not first check the point against the envelope of the ring.
Parameters:
p - p point to check for ring inclusion
ring - ring an array of coordinates representing the ring (which must have first point identical to last point)
Computes whether a ring defined by an array of
Coordinates is oriented counter-clockwise.
The list of points is assumed to have the first and last points equal.
This will handle coordinate lists which contain repeated points.
This algorithm is
only guaranteed to work with valid rings. If the ring is invalid (e.g. self-crosses or touches), the computed result may not be correct.
Parameters:
ring - ring an array of Coordinates forming a ring
Returns:
true if the ring is oriented counter-clockwise.
Throws:
IllegalArgumentException - IllegalArgumentException if there are too few points to determine orientation (< 4)
Computes the orientation of a point q to the directed line segment p1-p2. The orientation of a point relative to a directed line segment indicates which way you turn to get to q after travelling from p1 to p2.
Parameters:
p1 - p1 the first vertex of the line segment
p2 - p2 the second vertex of the line segment
q - q the point to compute the relative orientation of
Returns:
1 if q is counter-clockwise from p1-p2, or -1 if q is clockwise from p1-p2, or 0 if q is collinear with p1-p2
Computes the signed area for a ring. The signed area is positive if the ring is oriented CW, negative if the ring is oriented CCW, and zero if the ring is degenerate or flat.