GEOS 3.11.1
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
geos::geom::Triangle Class Reference

Represents a planar triangle, and provides methods for calculating various properties of triangles. More...

#include <Triangle.h>

Public Member Functions

 Triangle (const Coordinate &nP0, const Coordinate &nP1, const Coordinate &nP2)
 
void inCentre (Coordinate &resultPoint)
 The inCentre of a triangle is the point which is equidistant from the sides of the triangle. More...
 
void circumcentre (Coordinate &resultPoint)
 Computes the circumcentre of a triangle. More...
 
void circumcentreDD (Coordinate &resultPoint)
 
bool isIsoceles ()
 
bool intersects (const Coordinate &p)
 
bool isCCW ()
 
bool isAcute ()
 
double length () const
 
double area () const
 

Static Public Member Functions

static const Coordinate circumcentre (const Coordinate &p0, const Coordinate &p1, const Coordinate &p2)
 
static bool isAcute (const Coordinate &a, const Coordinate &b, const Coordinate &c)
 
static bool isCCW (const Coordinate &a, const Coordinate &b, const Coordinate &c)
 
static bool intersects (const Coordinate &a, const Coordinate &b, const Coordinate &c, const Coordinate &p)
 
static double longestSideLength (const Coordinate &a, const Coordinate &b, const Coordinate &c)
 
static double length (const Coordinate &a, const Coordinate &b, const Coordinate &c)
 
static double area (const Coordinate &a, const Coordinate &b, const Coordinate &c)
 

Public Attributes

Coordinate p0
 
Coordinate p1
 
Coordinate p2
 

Detailed Description

Represents a planar triangle, and provides methods for calculating various properties of triangles.

Member Function Documentation

◆ area()

static double geos::geom::Triangle::area ( const Coordinate a,
const Coordinate b,
const Coordinate c 
)
static

Computes the 2D area of a triangle. The area value is always non-negative.

Parameters
avertex of the triangle
bvertex of the triangle
cvertex of the triangle
Returns
the area of the triangle

◆ circumcentre() [1/2]

static const Coordinate geos::geom::Triangle::circumcentre ( const Coordinate p0,
const Coordinate p1,
const Coordinate p2 
)
static

Computes the circumcentre of a triangle.

◆ circumcentre() [2/2]

void geos::geom::Triangle::circumcentre ( Coordinate 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
resultPointthe point into which to write the inCentre of the triangle

◆ inCentre()

void geos::geom::Triangle::inCentre ( Coordinate 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
resultPointthe point into which to write the inCentre of the triangle

◆ intersects() [1/2]

static bool geos::geom::Triangle::intersects ( const Coordinate a,
const Coordinate b,
const Coordinate c,
const Coordinate p 
)
static

Tests whether a triangle intersects a point.

Parameters
aa vertex of the triangle
ba vertex of the triangle
ca vertex of the triangle
pthe point to test
Returns
true if the triangle intersects the point

◆ intersects() [2/2]

bool geos::geom::Triangle::intersects ( const Coordinate p)
inline

Tests whether a triangle intersects a point.

Parameters
pthe point to test
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 Coordinate a,
const Coordinate b,
const Coordinate 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
aa vertex of the triangle
ba vertex of the triangle
ca 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 Coordinate a,
const Coordinate b,
const Coordinate c 
)
static

Tests whether a triangle is oriented counter-clockwise.

Parameters
aa vertex of the triangle
ba vertex of the triangle
ca 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 Coordinate a,
const Coordinate b,
const Coordinate c 
)
static

Compute the length of the perimeter of a triangle

Parameters
aa vertex of the triangle
ba vertex of the triangle
ca vertex of the triangle
Returns
the length of the triangle perimeter

◆ longestSideLength()

static double geos::geom::Triangle::longestSideLength ( const Coordinate a,
const Coordinate b,
const Coordinate c 
)
static

Computes the length of the longest side of a triangle

Parameters
aa vertex of the triangle
ba vertex of the triangle
ca 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: