GEOS  3.10.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 #pragma once
20 
21 #include <geos/export.h>
22 #include <geos/inline.h>
23 #include <geos/math/DD.h>
24 
25 // Forward declarations
26 namespace geos {
27 namespace geom {
28 class Coordinate;
29 class CoordinateSequence;
30 }
31 }
32 
33 using namespace geos::math;
34 
35 namespace geos {
36 namespace algorithm { // geos::algorithm
37 
39 class GEOS_DLL CGAlgorithmsDD {
40 
41 public:
42 
43  enum {
44  CLOCKWISE = -1,
45  COLLINEAR = 0,
46  COUNTERCLOCKWISE = 1
47  };
48 
49  enum {
50  RIGHT = -1,
51  LEFT = 1,
52  STRAIGHT = 0,
53  FAILURE = 2
54  };
55 
68  static int orientationIndex(const geom::Coordinate& p1,
69  const geom::Coordinate& p2,
70  const geom::Coordinate& q);
71 
72 
73  static int orientationIndex(double p1x, double p1y,
74  double p2x, double p2y,
75  double qx, double qy);
76 
91  static int orientationIndexFilter(double pax, double pay,
92  double pbx, double pby,
93  double pcx, double pcy);
94 
95 
96  static int
97  orientation(double x)
98  {
99  if(x < 0) {
100  return CGAlgorithmsDD::RIGHT;
101  }
102  if(x > 0) {
103  return CGAlgorithmsDD::LEFT;
104  }
105  return CGAlgorithmsDD::STRAIGHT;
106  }
107 
118  const geom::Coordinate& q1, const geom::Coordinate& q2);
119 
120  static int signOfDet2x2(double dx1, double dy1, double dx2, double dy2);
121 
122  static DD detDD(double x1, double y1, double x2, double y2);
123  static DD detDD(const DD& x1, const DD& y1, const DD& x2, const DD& y2);
124 
149 
150 protected:
151 
152  static int signOfDet2x2(const DD& x1, const DD& y1, const DD& x2, const DD& y2);
153 
154 };
155 
156 } // namespace geos::algorithm
157 } // namespace geos
158 
159 #ifdef GEOS_INLINE
160 # include "geos/algorithm/CGAlgorithmsDD.inl"
161 #endif
162 
Implements basic computational geometry algorithms using extended precision float-point arithmetic.
Definition: CGAlgorithmsDD.h:39
static int orientationIndexFilter(double pax, double pay, double pbx, double pby, double pcx, double pcy)
static geom::Coordinate circumcentreDD(const geom::Coordinate &a, const geom::Coordinate &b, const geom::Coordinate &c)
Computes the circumcentre of a triangle.
static geom::Coordinate intersection(const geom::Coordinate &p1, const geom::Coordinate &p2, const geom::Coordinate &q1, const geom::Coordinate &q2)
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.
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Wrapper for DoubleDouble higher precision mathematics operations.
Definition: DD.h:108
Basic namespace for all GEOS functionalities.
Definition: Angle.h:26