Class Orientation
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.
Inherited Members
Namespace: NetTopologySuite.Algorithm
Assembly: NetTopologySuite.dll
Syntax
public static class Orientation
Methods
| Improve this Doc View SourceIndex(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 )
Declaration
public static OrientationIndex Index(Coordinate p1, Coordinate p2, Coordinate q)
Parameters
Type | Name | Description |
---|---|---|
Coordinate | p1 | The origin point of the line vector |
Coordinate | p2 | The final point of the line vector |
Coordinate | q | The point to compute the direction to |
Returns
Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
OrientationIndex | The OrientationIndex of q in regard to the vector
|
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).
Declaration
public static bool IsCCW(Coordinate[] ring)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | ring | An array of |
Returns
Type | Description |
---|---|
Boolean |
|
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).
Declaration
public static bool IsCCW(CoordinateSequence ring)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | ring | A |
Returns
Type | Description |
---|---|
Boolean |
|
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
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.)
Declaration
public static bool IsCCWArea(Coordinate[] ring)
Parameters
Type | Name | Description |
---|---|---|
Coordinate[] | ring | An array of Coordinates forming a ring (with first and last point identical) |
Returns
Type | Description |
---|---|
Boolean |
|
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
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.)
Declaration
public static bool IsCCWArea(CoordinateSequence ring)
Parameters
Type | Name | Description |
---|---|---|
CoordinateSequence | ring | An array of Coordinates forming a ring (with first and last point identical) |
Returns
Type | Description |
---|---|
Boolean |
|
ReOrient(OrientationIndex)
Re-orients an orientation.
Declaration
public static OrientationIndex ReOrient(OrientationIndex orientation)
Parameters
Type | Name | Description |
---|---|---|
OrientationIndex | orientation | The orientation |
Returns
Type | Description |
---|---|
OrientationIndex |