GEOS 3.11.1
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 Coordinate p0, p1, p2;
31
32 Triangle(const Coordinate& nP0, const Coordinate& nP1, const Coordinate& nP2)
33 : p0(nP0)
34 , p1(nP1)
35 , p2(nP2) {}
36
37
46 void inCentre(Coordinate& resultPoint);
47
65 void circumcentre(Coordinate& resultPoint);
66 void circumcentreDD(Coordinate& resultPoint);
67
70 const Coordinate& p0, const Coordinate& p1, const Coordinate& p2);
71
72 bool isIsoceles();
73
87 static bool isAcute(const Coordinate& a, const Coordinate& b, const Coordinate& c);
88
97 static bool isCCW(const Coordinate& a, const Coordinate& b, const Coordinate& c);
98
99
109 static bool intersects(const Coordinate& a, const Coordinate& b, const Coordinate& c,
110 const Coordinate& p);
111
112
118 bool intersects(const Coordinate& p) { return intersects(p0, p1, p2, p); };
119
124 bool isCCW() { return isCCW(p0, p1, p2); };
125
130 bool isAcute() { return isAcute(p0, p1, p2); };
131
140 static double longestSideLength(
141 const Coordinate& a,
142 const Coordinate& b,
143 const Coordinate& c);
144
153 static double length(const Coordinate& a, const Coordinate& b, const Coordinate& c);
154
160 double length() const;
161
171 static double area(const Coordinate& a, const Coordinate& b, const Coordinate& c);
172
173 double area() const;
174
175private:
176
191 double det(double m00, double m01, double m10, double m11) const;
192
193};
194
195
196
197} // namespace geos::geom
198} // namespace geos
199
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
Represents a planar triangle, and provides methods for calculating various properties of triangles.
Definition: Triangle.h:28
static bool isAcute(const Coordinate &a, const Coordinate &b, const Coordinate &c)
bool isCCW()
Definition: Triangle.h:124
bool isAcute()
Definition: Triangle.h:130
static double area(const Coordinate &a, const Coordinate &b, const Coordinate &c)
double length() const
static bool isCCW(const Coordinate &a, const Coordinate &b, const Coordinate &c)
static double longestSideLength(const Coordinate &a, const Coordinate &b, const Coordinate &c)
static double length(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:118
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: geos.h:39