Package org.meteoinfo.jts.algorithm
Class NonRobustCGAlgorithms
- java.lang.Object
-
- org.meteoinfo.jts.algorithm.CGAlgorithms
-
- org.meteoinfo.jts.algorithm.NonRobustCGAlgorithms
-
public class NonRobustCGAlgorithms extends CGAlgorithms
Non-robust versions of various fundamental Computational Geometric algorithms, FOR TESTING PURPOSES ONLY!. The non-robustness is due to rounding error in floating point computation.
-
-
Field Summary
-
Fields inherited from class org.meteoinfo.jts.algorithm.CGAlgorithms
CLOCKWISE, COLLINEAR, COUNTERCLOCKWISE, LEFT, RIGHT, STRAIGHT
-
-
Constructor Summary
Constructors Constructor Description NonRobustCGAlgorithms()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcomputeOrientation(Coordinate p1, Coordinate p2, Coordinate q)Computes the orientation of a point q to the directed line segment p1-p2.static doubledistanceLineLine(Coordinate A, Coordinate B, Coordinate C, Coordinate D)Computes the distance from a line segment AB to a line segment CD Note: NON-ROBUST!static booleanisCCW(Coordinate[] ring)Computes whether a ring defined by an array ofCoordinateis oriented counter-clockwise.static booleanisPointInRing(Coordinate p, Coordinate[] ring)Computes whether a ring defined by an array ofCoordinateis oriented counter-clockwise.static intorientationIndex(Coordinate p1, Coordinate p2, Coordinate q)Returns the index of the direction of the pointqrelative to a vector specified byp1-p2.-
Methods inherited from class org.meteoinfo.jts.algorithm.CGAlgorithms
distancePointLine, distancePointLine, distancePointLinePerpendicular, isOnLine, length, locatePointInRing, signedArea, signedArea
-
-
-
-
Method Detail
-
isPointInRing
public static boolean isPointInRing(Coordinate p, Coordinate[] ring)
Computes whether a ring defined by an array ofCoordinateis oriented counter-clockwise.This will handle coordinate lists which contain repeated points.
- Parameters:
ring- an array of coordinates forming a ring- Returns:
trueif the ring is oriented counter-clockwise.- Throws:
java.lang.IllegalArgumentException- if the ring is degenerate (does not contain 3 different points)
-
isCCW
public static boolean isCCW(Coordinate[] ring)
Computes whether a ring defined by an array ofCoordinateis oriented counter-clockwise.This will handle coordinate lists which contain repeated points.
- Parameters:
ring- an array of coordinates forming a ring- Returns:
trueif the ring is oriented counter-clockwise.- Throws:
java.lang.IllegalArgumentException- if the ring is degenerate (does not contain 3 different points)
-
computeOrientation
public static int computeOrientation(Coordinate p1, Coordinate p2, Coordinate q)
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.- Returns:
- 1 if q is counter-clockwise from p1-p2
-
orientationIndex
public static int orientationIndex(Coordinate p1, Coordinate p2, Coordinate q)
Returns the index of the direction of the pointqrelative to a vector specified byp1-p2.- Parameters:
p1- the origin point of the vectorp2- the final point of the vectorq- the point to compute the direction to- Returns:
- 1 if q is counter-clockwise (left) from p1-p2
-
distanceLineLine
public static double distanceLineLine(Coordinate A, Coordinate B, Coordinate C, Coordinate D)
Computes the distance from a line segment AB to a line segment CD Note: NON-ROBUST!- Parameters:
A- a point of one lineB- the second point of (must be different to A)C- one point of the lineD- another point of the line (must be different to A)
-
-