GEOS 3.14.0dev
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#pragma once
16
17#include <geos/export.h>
18#include <geos/geom/Coordinate.h>
19
20namespace geos {
21namespace geom { // geos::geom
22
28class GEOS_DLL Triangle {
29public:
30 CoordinateXY p0, p1, p2;
31
32 Triangle(const CoordinateXY& nP0, const CoordinateXY& nP1, const CoordinateXY& nP2)
33 : p0(nP0)
34 , p1(nP1)
35 , p2(nP2) {}
36
37
46 void inCentre(CoordinateXY& resultPoint);
47
65 void circumcentre(CoordinateXY& resultPoint);
66
70 void circumcentreDD(CoordinateXY& resultPoint);
71
80 static const CoordinateXY circumcentre(const CoordinateXY& p0, const CoordinateXY& p1, const CoordinateXY& p2);
81
91 static double circumradius(const CoordinateXY& a, const CoordinateXY& b, const CoordinateXY& c);
92
98 double circumradius() const
99 {
100 return circumradius(p0, p1, p2);
101 };
102
103 bool isIsoceles();
104
118 static bool isAcute(const CoordinateXY& a, const CoordinateXY& b, const CoordinateXY& c);
119
128 static bool isCCW(const CoordinateXY& a, const CoordinateXY& b, const CoordinateXY& c);
129
130
140 static bool intersects(const CoordinateXY& a, const CoordinateXY& b, const CoordinateXY& c,
141 const CoordinateXY& p);
142
143
149 bool intersects(const CoordinateXY& p) { return intersects(p0, p1, p2, p); };
150
155 bool isCCW() { return isCCW(p0, p1, p2); };
156
161 bool isAcute() { return isAcute(p0, p1, p2); };
162
171 static double longestSideLength(
172 const CoordinateXY& a,
173 const CoordinateXY& b,
174 const CoordinateXY& c);
175
184 static double length(const CoordinateXY& a, const CoordinateXY& b, const CoordinateXY& c);
185
191 double length() const;
192
202 static double area(const CoordinateXY& a, const CoordinateXY& b, const CoordinateXY& c);
203
204 double area() const;
205
206private:
207
222 double det(double m00, double m01, double m10, double m11) const;
223
224};
225
226
227
228} // namespace geos::geom
229} // namespace geos
230
Represents a planar triangle, and provides methods for calculating various properties of triangles.
Definition Triangle.h:28
bool isCCW()
Definition Triangle.h:155
bool isAcute()
Definition Triangle.h:161
double length() const
void circumcentre(CoordinateXY &resultPoint)
Computes the circumcentre of a triangle.
static bool isAcute(const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c)
static double circumradius(const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c)
double circumradius() const
Definition Triangle.h:98
static bool intersects(const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c, const CoordinateXY &p)
void circumcentreDD(CoordinateXY &resultPoint)
static bool isCCW(const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c)
void inCentre(CoordinateXY &resultPoint)
The inCentre of a triangle is the point which is equidistant from the sides of the triangle.
bool intersects(const CoordinateXY &p)
Definition Triangle.h:149
static double area(const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c)
static const CoordinateXY circumcentre(const CoordinateXY &p0, const CoordinateXY &p1, const CoordinateXY &p2)
static double length(const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c)
static double longestSideLength(const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c)
Basic namespace for all GEOS functionalities.
Definition geos.h:39