public class Orientation extends Object
Determining triangle 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.
Modifier and Type | Field and Description |
---|---|
static int |
CLOCKWISE
A value that indicates an orientation of clockwise, or a right turn.
|
static int |
COLLINEAR
A value that indicates an orientation of collinear, or no turn (straight).
|
static int |
COUNTERCLOCKWISE
A value that indicates an orientation of counterclockwise, or a left turn.
|
static int |
LEFT
A value that indicates an orientation of counterclockwise, or a left turn.
|
static int |
RIGHT
A value that indicates an orientation of clockwise, or a right turn.
|
static int |
STRAIGHT
A value that indicates an orientation of collinear, or no turn (straight).
|
Constructor and Description |
---|
Orientation() |
Modifier and Type | Method and Description |
---|---|
static int |
index(Coordinate p1,
Coordinate p2,
Coordinate q)
Returns the orientation index of the direction of the point
q relative to
a directed infinite line specified by p1-p2 . |
static boolean |
isCCW(Coordinate[] ring)
Tests if a ring defined by an array of
Coordinate s is
oriented counter-clockwise. |
static boolean |
isCCW(CoordinateSequence ring)
Tests if a ring defined by a
CoordinateSequence is
oriented counter-clockwise. |
static boolean |
isCCWArea(Coordinate[] ring)
Tests if a ring defined by an array of
Coordinate s is
oriented counter-clockwise, using the signed area of the ring. |
public static final int CLOCKWISE
public static final int RIGHT
public static final int COUNTERCLOCKWISE
public static final int LEFT
public static final int COLLINEAR
public static final int STRAIGHT
public static int index(Coordinate p1, Coordinate p2, Coordinate q)
q
relative to
a directed infinite line specified by p1-p2
.
The index indicates whether the point lies to the LEFT
or RIGHT
of the line, or lies on it COLLINEAR
.
The index also indicates the orientation of the triangle formed by the three points
( COUNTERCLOCKWISE
, CLOCKWISE
, or STRAIGHT
)p1
- the origin point of the line vectorp2
- the final point of the line vectorq
- the point to compute the direction toCLOCKWISE
or RIGHT
) if q is clockwise (right) from p1-p2;
1 ( COUNTERCLOCKWISE
or LEFT
) if q is counter-clockwise (left) from p1-p2;
0 ( COLLINEAR
or STRAIGHT
) if q is collinear with p1-p2public static boolean isCCW(Coordinate[] ring)
Coordinate
s is
oriented counter-clockwise.
ring
- an array of Coordinates forming a ring (with first and last point identical)IllegalArgumentException
- if there are too few points to determine orientation (< 4)public static boolean isCCW(CoordinateSequence ring)
CoordinateSequence
is
oriented counter-clockwise.
ring
- a CoordinateSequence forming a ring (with first and last point identical)IllegalArgumentException
- if there are too few points to determine orientation (< 4)public static boolean isCCWArea(Coordinate[] ring)
Coordinate
s is
oriented counter-clockwise, using the signed area of the ring.
However, this approach may be less accurate in the case of rings with almost zero area. (Note that the orientation of rings with zero area is essentially undefined, and hence non-deterministic.)
ring
- an array of Coordinates forming a ring (with first and last point identical)Copyright © 2020. All rights reserved.