Represents a planar triangle, and provides methods for calculating various properties of triangles.
More...
#include <Triangle.h>
|
| Triangle (const CoordinateXY &nP0, const CoordinateXY &nP1, const CoordinateXY &nP2) |
|
void | inCentre (CoordinateXY &resultPoint) |
| The inCentre of a triangle is the point which is equidistant from the sides of the triangle. More...
|
|
void | circumcentre (CoordinateXY &resultPoint) |
| Computes the circumcentre of a triangle. More...
|
|
void | circumcentreDD (CoordinateXY &resultPoint) |
|
double | circumradius () const |
|
bool | isIsoceles () |
|
bool | intersects (const CoordinateXY &p) |
|
bool | isCCW () |
|
bool | isAcute () |
|
double | length () const |
|
double | area () const |
|
|
static const CoordinateXY | circumcentre (const CoordinateXY &p0, const CoordinateXY &p1, const CoordinateXY &p2) |
|
static double | circumradius (const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c) |
|
static bool | isAcute (const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c) |
|
static bool | isCCW (const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c) |
|
static bool | intersects (const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c, const CoordinateXY &p) |
|
static double | longestSideLength (const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c) |
|
static double | length (const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c) |
|
static double | area (const CoordinateXY &a, const CoordinateXY &b, const CoordinateXY &c) |
|
|
CoordinateXY | p0 |
|
CoordinateXY | p1 |
|
CoordinateXY | p2 |
|
Represents a planar triangle, and provides methods for calculating various properties of triangles.
◆ area()
static double geos::geom::Triangle::area |
( |
const CoordinateXY & |
a, |
|
|
const CoordinateXY & |
b, |
|
|
const CoordinateXY & |
c |
|
) |
| |
|
static |
Computes the 2D area of a triangle. The area value is always non-negative.
- Parameters
-
a | vertex of the triangle |
b | vertex of the triangle |
c | vertex of the triangle |
- Returns
- the area of the triangle
◆ circumcentre() [1/2]
static const CoordinateXY geos::geom::Triangle::circumcentre |
( |
const CoordinateXY & |
p0, |
|
|
const CoordinateXY & |
p1, |
|
|
const CoordinateXY & |
p2 |
|
) |
| |
|
static |
Computes the circumcentre of a triangle. The circumcentre is the centre of the circumcircle, the smallest circle which passes through all the triangle vertices. It is also the common intersection point of the perpendicular bisectors of the
- Parameters
-
p0 | corner of the triangle |
p1 | corner of the triangle |
p2 | corner of the triangle |
- Returns
- the center of the the smallest circle that encloses the triangle
◆ circumcentre() [2/2]
void geos::geom::Triangle::circumcentre |
( |
CoordinateXY & |
resultPoint | ) |
|
Computes the circumcentre of a triangle.
The circumcentre is the centre of the circumcircle, the smallest circle which encloses the triangle. It is also the common intersection point of the perpendicular bisectors of the sides of the triangle, and is the only point which has equal distance to all three vertices of the triangle.
The circumcentre does not necessarily lie within the triangle. For example, the circumcentre of an obtuse isoceles triangle lies outside the triangle.
This method uses an algorithm due to J.R.Shewchuk which uses normalization to the origin to improve the accuracy of computation. (See Lecture Notes on Geometric Robustness, Jonathan Richard Shewchuk, 1999).
- Parameters
-
resultPoint | the point into which to write the inCentre of the triangle |
◆ circumcentreDD()
void geos::geom::Triangle::circumcentreDD |
( |
CoordinateXY & |
resultPoint | ) |
|
Calculates the circumcentre using double precision math
- Parameters
-
resultPoint | the point into which to write the inCentre of the triangle |
◆ circumradius() [1/2]
double geos::geom::Triangle::circumradius |
( |
| ) |
const |
|
inline |
Computes the radius of the circumcircle of a triangle.
- Returns
- the triangle circumradius
◆ circumradius() [2/2]
static double geos::geom::Triangle::circumradius |
( |
const CoordinateXY & |
a, |
|
|
const CoordinateXY & |
b, |
|
|
const CoordinateXY & |
c |
|
) |
| |
|
static |
Computes the radius of the circumcircle of a triangle. Formula is as per https://math.stackexchange.com/a/3610959
- Parameters
-
a | a vertex of the triangle |
b | a vertex of the triangle |
c | a vertex of the triangle |
- Returns
- the circumradius of the triangle
◆ inCentre()
void geos::geom::Triangle::inCentre |
( |
CoordinateXY & |
resultPoint | ) |
|
The inCentre of a triangle is the point which is equidistant from the sides of the triangle.
This is also the point at which the bisectors of the angles meet.
- Parameters
-
resultPoint | the point into which to write the inCentre of the triangle |
◆ intersects() [1/2]
static bool geos::geom::Triangle::intersects |
( |
const CoordinateXY & |
a, |
|
|
const CoordinateXY & |
b, |
|
|
const CoordinateXY & |
c, |
|
|
const CoordinateXY & |
p |
|
) |
| |
|
static |
Tests whether a triangle intersects a point.
- Parameters
-
a | a vertex of the triangle |
b | a vertex of the triangle |
c | a vertex of the triangle |
p | the point to test |
- Returns
- true if the triangle intersects the point
◆ intersects() [2/2]
bool geos::geom::Triangle::intersects |
( |
const CoordinateXY & |
p | ) |
|
|
inline |
Tests whether a triangle intersects a point.
- Parameters
-
- Returns
- true if the triangle intersects the point
References intersects().
Referenced by intersects().
◆ isAcute() [1/2]
bool geos::geom::Triangle::isAcute |
( |
| ) |
|
|
inline |
Tests whether this triangle is acute.
- Returns
- true if this triangle is acute
References isAcute().
Referenced by isAcute().
◆ isAcute() [2/2]
static bool geos::geom::Triangle::isAcute |
( |
const CoordinateXY & |
a, |
|
|
const CoordinateXY & |
b, |
|
|
const CoordinateXY & |
c |
|
) |
| |
|
static |
Tests whether a triangle is acute. A triangle is acute if all interior angles are acute. This is a strict test - right triangles will return false
. A triangle which is not acute is either right or obtuse.
Note: this implementation is not robust for angles very close to 90 degrees.
- Parameters
-
a | a vertex of the triangle |
b | a vertex of the triangle |
c | a vertex of the triangle |
- Returns
- true if the triangle is acute
◆ isCCW() [1/2]
bool geos::geom::Triangle::isCCW |
( |
| ) |
|
|
inline |
Tests whether this triangle is oriented counter-clockwise.
- Returns
- true if the triangle orientation is counter-clockwise
References isCCW().
Referenced by isCCW().
◆ isCCW() [2/2]
static bool geos::geom::Triangle::isCCW |
( |
const CoordinateXY & |
a, |
|
|
const CoordinateXY & |
b, |
|
|
const CoordinateXY & |
c |
|
) |
| |
|
static |
Tests whether a triangle is oriented counter-clockwise.
- Parameters
-
a | a vertex of the triangle |
b | a vertex of the triangle |
c | a vertex of the triangle |
- Returns
- true if the triangle orientation is counter-clockwise
◆ length() [1/2]
double geos::geom::Triangle::length |
( |
| ) |
const |
Computes the length of the perimeter of this triangle.
- Returns
- the length of the perimeter
◆ length() [2/2]
static double geos::geom::Triangle::length |
( |
const CoordinateXY & |
a, |
|
|
const CoordinateXY & |
b, |
|
|
const CoordinateXY & |
c |
|
) |
| |
|
static |
Compute the length of the perimeter of a triangle
- Parameters
-
a | a vertex of the triangle |
b | a vertex of the triangle |
c | a vertex of the triangle |
- Returns
- the length of the triangle perimeter
◆ longestSideLength()
static double geos::geom::Triangle::longestSideLength |
( |
const CoordinateXY & |
a, |
|
|
const CoordinateXY & |
b, |
|
|
const CoordinateXY & |
c |
|
) |
| |
|
static |
Computes the length of the longest side of a triangle
- Parameters
-
a | a vertex of the triangle |
b | a vertex of the triangle |
c | a vertex of the triangle |
- Returns
- the length of the longest side of the triangle
The documentation for this class was generated from the following file: