Class Orientation
- Namespace
- NetTopologySuite.Algorithm
- Assembly
- NetTopologySuite.dll
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).
Determining triangle orientation is notoriously subject to numerical precision errors in the case of collinear or nearly collinear points. NTS uses extended-precision arithmetic to increase the robustness of the computation.public static class Orientation
- Inheritance
-
Orientation
- Inherited Members
Methods
Index(Coordinate, Coordinate, Coordinate)
Returns the orientation index of the direction of the point 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 )
public static OrientationIndex Index(Coordinate p1, Coordinate p2, Coordinate q)
Parameters
p1
CoordinateThe origin point of the line vector
p2
CoordinateThe final point of the line vector
q
CoordinateThe point to compute the direction to
Returns
- OrientationIndex
The OrientationIndex of q in regard to the vector
p1->p2
Value Description Collinear, Straight q
is collinear withp1->p2
Clockwise, Right q
is clockwise (right) fromp1->p2
CounterClockwise, Left q
is counter-clockwise (left) fromp1->p2
IsCCW(CoordinateSequence)
Tests if a ring defined by a CoordinateSequence is oriented counter-clockwise.
- The list of points is assumed to have the first and last points equal.
- This handles coordinate lists which contain repeated points.
- This handles rings which contain collapsed segments (in particular, along the top of the ring).
public static bool IsCCW(CoordinateSequence ring)
Parameters
ring
CoordinateSequenceA
CoordinateSequence
s forming a ring (with first and last point identical).
Returns
- bool
true
if the ring is oriented counter-clockwise.
IsCCW(Coordinate[])
Tests if 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 handles coordinate lists which contain repeated points.
- This handles rings which contain collapsed segments (in particular, along the top of the ring).
public static bool IsCCW(Coordinate[] ring)
Parameters
ring
Coordinate[]An array of
Coordinate
s forming a ring (with first and last point identical)
Returns
- bool
true
if the ring is oriented counter-clockwise.
IsCCWArea(CoordinateSequence)
Tests if a ring defined by a CoordinateSequence is oriented counter-clockwise, using the signed area of the ring.
- The list of points is assumed to have the first and last points equal.
- This handles coordinate lists which contain repeated points.
- This handles rings which contain collapsed segments (in particular, along the top of the ring).
- This handles rings which are invalid due to self-intersection
public static bool IsCCWArea(CoordinateSequence ring)
Parameters
ring
CoordinateSequenceAn array of Coordinates forming a ring (with first and last point identical)
Returns
- bool
true
if the ring is oriented counter-clockwise.
IsCCWArea(Coordinate[])
Tests if a ring defined by an array of Coordinates is oriented counter-clockwise, using the signed area of the ring.
- The list of points is assumed to have the first and last points equal.
- This handles coordinate lists which contain repeated points.
- This handles rings which contain collapsed segments (in particular, along the top of the ring).
- This handles rings which are invalid due to self-intersection
public static bool IsCCWArea(Coordinate[] ring)
Parameters
ring
Coordinate[]An array of Coordinates forming a ring (with first and last point identical)
Returns
- bool
true
if the ring is oriented counter-clockwise.
ReOrient(OrientationIndex)
Re-orients an orientation.
public static OrientationIndex ReOrient(OrientationIndex orientation)
Parameters
orientation
OrientationIndexThe orientation