Package org.locationtech.jts.algorithm
Class Orientation
- java.lang.Object
-
- org.locationtech.jts.algorithm.Orientation
-
public class Orientation extends Object
Functions to compute the orientation of basic geometric structures including point triplets (triangles) and rings. Orientation is a fundamental property of planar geometries (and more generally geometry on two-dimensional manifolds).Orientation is notoriously subject to numerical precision errors in the case of collinear or nearly collinear points. JTS uses extended-precision arithmetic to increase the robustness of the computation.
- Author:
- Martin Davis
-
-
Field Summary
Fields Modifier and Type Field Description static intCLOCKWISEA value that indicates an orientation of clockwise, or a right turn.static intCOLLINEARA value that indicates an orientation of collinear, or no turn (straight).static intCOUNTERCLOCKWISEA value that indicates an orientation of counterclockwise, or a left turn.static intLEFTA value that indicates an orientation of counterclockwise, or a left turn.static intRIGHTA value that indicates an orientation of clockwise, or a right turn.static intSTRAIGHTA value that indicates an orientation of collinear, or no turn (straight).
-
Constructor Summary
Constructors Constructor Description Orientation()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intindex(Coordinate p1, Coordinate p2, Coordinate q)Returns the orientation index of the direction of the pointqrelative to a directed infinite line specified byp1-p2.static booleanisCCW(Coordinate[] ring)Computes whether a ring defined by an array ofCoordinates is oriented counter-clockwise.static booleanisCCW(CoordinateSequence ring)Computes whether a ring defined by anCoordinateSequenceis oriented counter-clockwise.
-
-
-
Field Detail
-
CLOCKWISE
public static final int CLOCKWISE
A value that indicates an orientation of clockwise, or a right turn.- See Also:
- Constant Field Values
-
RIGHT
public static final int RIGHT
A value that indicates an orientation of clockwise, or a right turn.- See Also:
- Constant Field Values
-
COUNTERCLOCKWISE
public static final int COUNTERCLOCKWISE
A value that indicates an orientation of counterclockwise, or a left turn.- See Also:
- Constant Field Values
-
LEFT
public static final int LEFT
A value that indicates an orientation of counterclockwise, or a left turn.- See Also:
- Constant Field Values
-
COLLINEAR
public static final int COLLINEAR
A value that indicates an orientation of collinear, or no turn (straight).- See Also:
- Constant Field Values
-
STRAIGHT
public static final int STRAIGHT
A value that indicates an orientation of collinear, or no turn (straight).- See Also:
- Constant Field Values
-
-
Method Detail
-
index
public static int index(Coordinate p1, Coordinate p2, Coordinate q)
Returns the orientation index of the direction of the pointqrelative to a directed infinite line specified byp1-p2. The index indicates whether the point lies to theLEFTorRIGHTof the line, or lies on itCOLLINEAR. The index also indicates the orientation of the triangle formed by the three points (COUNTERCLOCKWISE,CLOCKWISE, orSTRAIGHT)- Parameters:
p1- the origin point of the line vectorp2- the final point of the line vectorq- the point to compute the direction to- Returns:
- -1 (
CLOCKWISEorRIGHT) if q is clockwise (right) from p1-p2; 1 (COUNTERCLOCKWISEorLEFT) if q is counter-clockwise (left) from p1-p2; 0 (COLLINEARorSTRAIGHT) if q is collinear with p1-p2
-
isCCW
public static boolean isCCW(Coordinate[] ring)
Computes whether a ring defined by an array ofCoordinates 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.
- Parameters:
ring- an array of Coordinates forming a ring- Returns:
- true if the ring is oriented counter-clockwise.
- Throws:
IllegalArgumentException- if there are too few points to determine orientation (< 4)
-
isCCW
public static boolean isCCW(CoordinateSequence ring)
Computes whether a ring defined by anCoordinateSequenceis 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.
- Parameters:
ring- a CoordinateSequence forming a ring- Returns:
- true if the ring is oriented counter-clockwise.
- Throws:
IllegalArgumentException- if there are too few points to determine orientation (< 4)
-
-