GEOS 3.6.2
Angle.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2009-2011 Sandro Santilli <strk@keybit.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/Angle.java r378 (JTS-1.12)
16 *
17 **********************************************************************/
18
19#ifndef GEOS_ALGORITHM_ANGLE_H
20#define GEOS_ALGORITHM_ANGLE_H
21
22#include <geos/export.h>
23#include <geos/algorithm/CGAlgorithms.h> // for constants
24
25// Forward declarations
26namespace geos {
27 namespace geom {
28 class Coordinate;
29 }
30}
31
32namespace geos {
33namespace algorithm { // geos::algorithm
34
36//
39class GEOS_DLL Angle
40{
41public:
42
43 static const double PI_TIMES_2; // 2.0 * PI;
44 static const double PI_OVER_2; // PI / 2.0;
45 static const double PI_OVER_4; // PI / 4.0;
46
48 static const int COUNTERCLOCKWISE = CGAlgorithms::COUNTERCLOCKWISE;
49
51 static const int CLOCKWISE = CGAlgorithms::CLOCKWISE;
52
54 static const int NONE = CGAlgorithms::COLLINEAR;
55
57 //
61 static double toDegrees(double radians);
62
64 //
68 static double toRadians(double angleDegrees);
69
73 //
79 static double angle(const geom::Coordinate& p0,
80 const geom::Coordinate& p1);
81
85 //
91 static double angle(const geom::Coordinate& p);
92
94 //
104 static bool isAcute(const geom::Coordinate& p0,
105 const geom::Coordinate& p1,
106 const geom::Coordinate& p2);
107
109 //
119 static bool isObtuse(const geom::Coordinate& p0,
120 const geom::Coordinate& p1,
121 const geom::Coordinate& p2);
122
124 //
132 static double angleBetween(const geom::Coordinate& tip1,
133 const geom::Coordinate& tail,
134 const geom::Coordinate& tip2);
135
137 //
148 static double angleBetweenOriented(const geom::Coordinate& tip1,
149 const geom::Coordinate& tail,
150 const geom::Coordinate& tip2);
151
153 //
165 static double interiorAngle(const geom::Coordinate& p0,
166 const geom::Coordinate& p1,
167 const geom::Coordinate& p2);
168
178 static int getTurn(double ang1, double ang2);
179
187 static double normalize(double angle);
188
207 static double normalizePositive(double angle);
208
209
211 //
220 static double diff(double ang1, double ang2);
221};
222
223
224} // namespace geos::algorithm
225} // namespace geos
226
227
228#endif // GEOS_ALGORITHM_ANGLE_H
Utility functions for working with angles.
Definition Angle.h:40
static double diff(double ang1, double ang2)
Computes the unoriented smallest difference between two angles.
static double angle(const geom::Coordinate &p0, const geom::Coordinate &p1)
Returns the angle of the vector from p0 to p1, relative to the positive X-axis.
static double angleBetween(const geom::Coordinate &tip1, const geom::Coordinate &tail, const geom::Coordinate &tip2)
Returns the unoriented smallest angle between two vectors.
static bool isObtuse(const geom::Coordinate &p0, const geom::Coordinate &p1, const geom::Coordinate &p2)
Tests whether the angle between p0-p1-p2 is obtuse.
static int getTurn(double ang1, double ang2)
Returns whether an angle must turn clockwise or counterclockwise to overlap another angle.
static const int CLOCKWISE
Constant representing clockwise orientation.
Definition Angle.h:51
static const int COUNTERCLOCKWISE
Constant representing counterclockwise orientation.
Definition Angle.h:48
static const int NONE
Constant representing no orientation.
Definition Angle.h:54
static double interiorAngle(const geom::Coordinate &p0, const geom::Coordinate &p1, const geom::Coordinate &p2)
Computes the interior angle between two segments of a ring.
static bool isAcute(const geom::Coordinate &p0, const geom::Coordinate &p1, const geom::Coordinate &p2)
Tests whether the angle between p0-p1-p2 is acute.
static double toDegrees(double radians)
Converts from radians to degrees.
static double normalizePositive(double angle)
Computes the normalized positive value of an angle, which is the equivalent angle in the range [ 0,...
static double normalize(double angle)
Computes the normalized value of an angle, which is the equivalent angle in the range ( -Pi,...
static double toRadians(double angleDegrees)
Converts from degrees to radians.
static double angle(const geom::Coordinate &p)
Returns the angle that the vector from (0,0) to p, relative to the positive X-axis.
static double angleBetweenOriented(const geom::Coordinate &tip1, const geom::Coordinate &tail, const geom::Coordinate &tip2)
Returns the oriented smallest angle between two vectors.
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:33
Contains the Geometry interface hierarchy and supporting classes.
Definition IndexedNestedRingTester.h:26
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:25