GEOS  3.10.3
Triangle.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2006 Refractions Research Inc.
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 #ifndef GEOS_GEOM_TRIANGLE_H
16 #define GEOS_GEOM_TRIANGLE_H
17 
18 #include <geos/export.h>
19 #include <geos/geom/Coordinate.h>
20 
21 #include <geos/inline.h>
22 
23 namespace geos {
24 namespace geom { // geos::geom
25 
31 class GEOS_DLL Triangle {
32 public:
33  Coordinate p0, p1, p2;
34 
35  Triangle(const Coordinate& nP0, const Coordinate& nP1, const Coordinate& nP2)
36  : p0(nP0)
37  , p1(nP1)
38  , p2(nP2) {}
39 
40 
49  void inCentre(Coordinate& resultPoint);
50 
68  void circumcentre(Coordinate& resultPoint);
69  void circumcentreDD(Coordinate& resultPoint);
70 
72  static const Coordinate circumcentre(
73  const Coordinate& p0, const Coordinate& p1, const Coordinate& p2);
74 
75  bool isIsoceles();
76 
90  static bool isAcute(const Coordinate& a, const Coordinate& b, const Coordinate& c);
91 
100  static bool isCCW(const Coordinate& a, const Coordinate& b, const Coordinate& c);
101 
102 
112  static bool intersects(const Coordinate& a, const Coordinate& b, const Coordinate& c,
113  const Coordinate& p);
114 
115 
121  bool intersects(const Coordinate& p) { return intersects(p0, p1, p2, p); };
122 
127  bool isCCW() { return isCCW(p0, p1, p2); };
128 
133  bool isAcute() { return isAcute(p0, p1, p2); };
134 
135 
136 
137 private:
138 
153  double det(double m00, double m01, double m10, double m11) const;
154 
155 };
156 
157 
158 } // namespace geos::geom
159 } // namespace geos
160 
161 //#ifdef GEOS_INLINE
162 //# include "geos/geom/Triangle.inl"
163 //#endif
164 
165 #endif // ndef GEOS_GEOM_TRIANGLE_H
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Represents a planar triangle, and provides methods for calculating various properties of triangles.
Definition: Triangle.h:31
static bool isAcute(const Coordinate &a, const Coordinate &b, const Coordinate &c)
bool isCCW()
Definition: Triangle.h:127
bool isAcute()
Definition: Triangle.h:133
static bool isCCW(const Coordinate &a, const Coordinate &b, const Coordinate &c)
void circumcentre(Coordinate &resultPoint)
Computes the circumcentre of a triangle.
bool intersects(const Coordinate &p)
Definition: Triangle.h:121
static const Coordinate circumcentre(const Coordinate &p0, const Coordinate &p1, const Coordinate &p2)
void inCentre(Coordinate &resultPoint)
The inCentre of a triangle is the point which is equidistant from the sides of the triangle.
static bool intersects(const Coordinate &a, const Coordinate &b, const Coordinate &c, const Coordinate &p)
Basic namespace for all GEOS functionalities.
Definition: Angle.h:26