GEOS  3.8.0dev
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.
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>
23
24 // Close to DoubleDouble equivalent used by JTS
25 // Usage: ttmath::Big<exponent, mantissa>
27 //typedef ttmath::Big<TTMATH_BITS(64), TTMATH_BITS(128)> DD;
28 //typedef ttmath::Big<TTMATH_BITS(32), TTMATH_BITS(256)> DD;
29 //typedef ttmath::Big<TTMATH_BITS(64), TTMATH_BITS(256)> DD;
30
31 // Forward declarations
32 namespace geos {
33 namespace geom {
34 class Coordinate;
35 class CoordinateSequence;
36 }
37 }
38
39 namespace geos {
40 namespace algorithm { // geos::algorithm
45 class GEOS_DLL CGAlgorithmsDD {
46
47 public:
48
49  enum {
50  CLOCKWISE = -1,
51  COLLINEAR = 0,
52  COUNTERCLOCKWISE = 1
53  };
54
55  enum {
56  RIGHT = -1,
57  LEFT = 1,
58  STRAIGHT = 0,
59  FAILURE = 2
60  };
61
74  static int orientationIndex(const geom::Coordinate& p1,
75  const geom::Coordinate& p2,
76  const geom::Coordinate& q);
97  static int orientationIndexFilter(const geom::Coordinate& pa,
98  const geom::Coordinate& pb,
99  const geom::Coordinate& pc);
100
101  static int
102  orientation(double x)
103  {
104  if(x < 0) {
105  return CGAlgorithmsDD::RIGHT;
106  }
107  if(x > 0) {
108  return CGAlgorithmsDD::LEFT;
109  }
110  return CGAlgorithmsDD::STRAIGHT;
111  }
112
113  static void intersection(const geom::Coordinate& p1, const geom::Coordinate& p2,
114  const geom::Coordinate& q1, const geom::Coordinate& q2,
115  geom::Coordinate& rv);
116
117  static int signOfDet2x2(double dx1, double dy1, double dx2, double dy2);
118
119
120 protected:
121
122  static int signOfDet2x2(DD& x1, DD& y1, DD& x2, DD& y2);
123
124 };
125
126 } // namespace geos::algorithm
127 } // namespace geos
128
129 #endif // GEOS_ALGORITHM_CGALGORITHM_H
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Implements basic computational geometry algorithms using extended precision float-point arithmetic...
Definition: CGAlgorithmsDD.h:45
Big implements the floating point numbers.
Definition: ttmathbig.h:63
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Mathematics functions.