GEOS  3.8.1
CGAlgorithmsDD.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2014 Mateusz Loskot <mateusz@loskot.net>
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************
14  *
15  * Last port: algorithm/CGAlgorithmsDD.java r789 (JTS-1.14)
16  *
17  **********************************************************************/
18 
19 #ifndef GEOS_ALGORITHM_CGALGORITHMDD_H
20 #define GEOS_ALGORITHM_CGALGORITHMDD_H
21 #include <geos/export.h>
22 #include <geos/math/DD.h>
23 
24 // Forward declarations
25 namespace geos {
26 namespace geom {
27 class Coordinate;
28 class CoordinateSequence;
29 }
30 }
31 
32 using namespace geos::math;
33 
34 namespace geos {
35 namespace algorithm { // geos::algorithm
36 
38 class GEOS_DLL CGAlgorithmsDD {
39 
40 public:
41 
42  enum {
43  CLOCKWISE = -1,
44  COLLINEAR = 0,
45  COUNTERCLOCKWISE = 1
46  };
47 
48  enum {
49  RIGHT = -1,
50  LEFT = 1,
51  STRAIGHT = 0,
52  FAILURE = 2
53  };
54 
67  static int orientationIndex(const geom::Coordinate& p1,
68  const geom::Coordinate& p2,
69  const geom::Coordinate& q);
91  const geom::Coordinate& pb,
92  const geom::Coordinate& pc);
93 
94  static int
95  orientation(double x)
96  {
97  if(x < 0) {
98  return CGAlgorithmsDD::RIGHT;
99  }
100  if(x > 0) {
101  return CGAlgorithmsDD::LEFT;
102  }
103  return CGAlgorithmsDD::STRAIGHT;
104  }
105 
116  const geom::Coordinate& q1, const geom::Coordinate& q2);
117 
118  static int signOfDet2x2(double dx1, double dy1, double dx2, double dy2);
119 
120  static DD detDD(double x1, double y1, double x2, double y2);
121  static DD detDD(const DD& x1, const DD& y1, const DD& x2, const DD& y2);
122 
147 
148 protected:
149 
150  static int signOfDet2x2(const DD& x1, const DD& y1, const DD& x2, const DD& y2);
151 
152 };
153 
154 } // namespace geos::algorithm
155 } // namespace geos
156 
157 #endif // GEOS_ALGORITHM_CGALGORITHM_H
geos::algorithm::CGAlgorithmsDD::intersection
static geom::Coordinate intersection(const geom::Coordinate &p1, const geom::Coordinate &p2, const geom::Coordinate &q1, const geom::Coordinate &q2)
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::math::DD
Wrapper for DoubleDouble higher precision mathematics operations.
Definition: DD.h:132
geos::algorithm::CGAlgorithmsDD::orientationIndex
static int orientationIndex(const geom::Coordinate &p1, const geom::Coordinate &p2, const geom::Coordinate &q)
Returns the index of the direction of the point q relative to a vector specified by p1-p2.
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:84
geos::algorithm::CGAlgorithmsDD::circumcentreDD
static geom::Coordinate circumcentreDD(const geom::Coordinate &a, const geom::Coordinate &b, const geom::Coordinate &c)
Computes the circumcentre of a triangle.
geos::algorithm::CGAlgorithmsDD
Implements basic computational geometry algorithms using extended precision float-point arithmetic.
Definition: CGAlgorithmsDD.h:38
geos::algorithm::CGAlgorithmsDD::orientationIndexFilter
static int orientationIndexFilter(const geom::Coordinate &pa, const geom::Coordinate &pb, const geom::Coordinate &pc)
A filter for computing the orientation index of three coordinates.