GEOS  3.11.1
Angle.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2009-2011 Sandro Santilli <strk@kbt.io>
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/Angle.java r378 (JTS-1.12)
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/export.h>
22 #include <geos/algorithm/Orientation.h> // for constants
23 
24 // Forward declarations
25 namespace geos {
26 namespace geom {
27 class Coordinate;
28 }
29 }
30 
31 namespace geos {
32 namespace algorithm { // geos::algorithm
33 
35 //
38 class GEOS_DLL Angle {
39 public:
40 
41  static constexpr double PI_TIMES_2 = 2.0 * MATH_PI;
42  static constexpr double PI_OVER_2 = MATH_PI / 2.0;
43  static constexpr double PI_OVER_4 = MATH_PI / 4.0;
44 
46  static const int COUNTERCLOCKWISE = Orientation::COUNTERCLOCKWISE;
47 
49  static const int CLOCKWISE = Orientation::CLOCKWISE;
50 
52  static const int NONE = Orientation::COLLINEAR;
53 
59  static double toDegrees(double radians);
60 
66  static double toRadians(double angleDegrees);
67 
77  static double angle(const geom::Coordinate& p0,
78  const geom::Coordinate& p1);
79 
83  //
89  static double angle(const geom::Coordinate& p);
90 
102  static bool isAcute(const geom::Coordinate& p0,
103  const geom::Coordinate& p1,
104  const geom::Coordinate& p2);
105 
117  static bool isObtuse(const geom::Coordinate& p0,
118  const geom::Coordinate& p1,
119  const geom::Coordinate& p2);
120 
130  static double angleBetween(const geom::Coordinate& tip1,
131  const geom::Coordinate& tail,
132  const geom::Coordinate& tip2);
133 
146  static double angleBetweenOriented(const geom::Coordinate& tip1,
147  const geom::Coordinate& tail,
148  const geom::Coordinate& tip2);
149 
163  static double interiorAngle(const geom::Coordinate& p0,
164  const geom::Coordinate& p1,
165  const geom::Coordinate& p2);
166 
176  static int getTurn(double ang1, double ang2);
177 
185  static double normalize(double angle);
186 
205  static double normalizePositive(double angle);
206 
207 
218  static double diff(double ang1, double ang2);
219 };
220 
221 
222 } // namespace geos::algorithm
223 } // namespace geos
224 
225 
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25
Utility functions for working with angles.
Definition: Angle.h:38