GEOS  3.9.1dev
MinimumBoundingCircle.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2019 Paul Ramsey <pramsey@cleverelephant.ca>
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/MinimumBoundingCircle.java 2019-01-23
16  *
17  **********************************************************************/
18 
19 #ifndef GEOS_ALGORITHM_MINIMUMBOUNDINGCIRCLE_H
20 #define GEOS_ALGORITHM_MINIMUMBOUNDINGCIRCLE_H
21 
22 #include <geos/export.h>
23 #include <geos/geom/Coordinate.h>
25 #include <geos/geom/Geometry.h>
26 #include <geos/geom/Point.h>
27 #include <geos/geom/Triangle.h>
28 
29 #include <vector>
30 
31 // Forward declarations
32 // namespace geos {
33 // namespace geom {
34 // class GeometryCollection;
35 // }
36 // }
37 
38 
39 namespace geos {
40 namespace algorithm { // geos::algorithm
41 
43 
44 private:
45 
46  // member variables
48  std::vector<geom::Coordinate> extremalPts;
50  double radius;
51 
52  void computeCentre();
53  void compute();
54  void computeCirclePoints();
55  geom::Coordinate lowestPoint(std::vector<geom::Coordinate>& pts);
56  geom::Coordinate pointWitMinAngleWithX(std::vector<geom::Coordinate>& pts, geom::Coordinate& P);
57  geom::Coordinate pointWithMinAngleWithSegment(std::vector<geom::Coordinate>& pts,
59  std::vector<geom::Coordinate> farthestPoints(std::vector<geom::Coordinate>& pts);
60 
61 
62 public:
63 
65  input(nullptr),
66  radius(0.0)
67  {
68  input = geom;
69  centre.setNull();
70  }
71 
73 
85  std::unique_ptr<geom::Geometry> getCircle();
86 
97  std::unique_ptr<geom::Geometry> getMaximumDiameter();
98 
107  std::unique_ptr<geom::Geometry> getDiameter();
108 
117  std::vector<geom::Coordinate> getExtremalPoints();
118 
125  geom::Coordinate getCentre();
126 
132  double getRadius();
133 
134 };
135 
136 } // namespace geos::algorithm
137 } // namespace geos
138 
139 #endif // GEOS_ALGORITHM_MINIMUMBOUNDINGCIRCLE_H
140 
#define GEOS_DLL
Definition: export.h:28
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
std::vector< geom::Coordinate > extremalPts
MinimumBoundingCircle(const geom::Geometry *geom)
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Basic namespace for all GEOS functionalities.