Visual Computing Library
Loading...
Searching...
No Matches
vcl::Triangle< PointT > Class Template Reference

Public Types

using ScalarType = PointT::ScalarType
 
using PointType = PointT
 

Public Member Functions

 Triangle (const PointT &p0, const PointT &p1, const PointT &p2)
 
constexpr uint size () const
 Returns the number of points of the triangle.
 
const PointT & point (uint i) const
 Returns the i-th point of the triangle.
 
PointT & point (uint i)
 
PointT & point0 ()
 
const PointT & point0 () const
 
PointT & point1 ()
 
const PointT & point1 () const
 
PointT & point2 ()
 
const PointT & point2 () const
 
ScalarType sideLength (uint i) const
 Returns the length of the i-th side of the triangle.
 
ScalarType sideLength0 () const
 Returns the length of the first side of the triangle.
 
ScalarType sideLength1 () const
 Returns the length of the second side of the triangle.
 
ScalarType sideLength2 () const
 Returns the length of the third side of the triangle.
 
PointT normal () const
 Returns the normal of the triangle.
 
PointT barycenter () const
 Computes the barycenter of the triangle.
 
PointT weightedBarycenter (ScalarType w0, ScalarType w1, ScalarType w2) const
 Computes the weighted barycenter of the triangle.
 
PointT weightedBarycenter (const Point3< ScalarType > &w) const
 Computes the weighted barycenter of the triangle.
 
PointT barycentricCoordinatePoint (ScalarType b0, ScalarType b1, ScalarType b2) const
 
PointT barycentricCoordinatePoint (const Point3< ScalarType > &b) const
 Computes the point in the triangle with the given barycentric coordinates.
 
PointT circumcenter () const
 Compute the circumcenter of the triangle.
 
ScalarType perimeter () const
 Computes the perimeter of the triangle.
 
ScalarType area () const
 Computes the area of the triangle.
 
ScalarType quality () const
 Calculates the quality measure of the triangle.
 
ScalarType qualityRadii () const
 Compute a shape quality measure of the triangle.
 
ScalarType qualityMeanRatio () const
 Compute the mean ratio of the triangle shape quality measure.
 
ScalarType sideLength (const PointT &p0, const PointT &p1, const PointT &p2, uint i) const
 Returns the length of the i-th side of the triangle composed by the points p0, p1, and p2.
 

Static Public Member Functions

static PointT normal (const PointT &p0, const PointT &p1, const PointT &p2)
 Computes the normal of the triangle composed by the 3D points p0, p1, and p2, considering that these three points are ordered in counter-clockwise order.
 
static PointT barycenter (const PointT &p0, const PointT &p1, const PointT &p2)
 Computes the barycenter of the triangle composed by the points p0, p1, and p2.
 
static PointT weightedBarycenter (const PointT &p0, const PointT &p1, const PointT &p2, ScalarType w0, ScalarType w1, ScalarType w2)
 Computes the weighted barycenter of a triangle composed of three points.
 
static PointT barycentricCoordinatePoint (const PointT &p0, const PointT &p1, const PointT &p2, ScalarType b0, ScalarType b1, ScalarType b2)
 Computes the point in a triangle with the given barycentric coordinates.
 
static PointT circumcenter (const PointT &p0, const PointT &p1, const PointT &p2)
 Compute the circumcenter of a triangle.
 
static ScalarType perimeter (const PointT &p0, const PointT &p1, const PointT &p2)
 Computes the perimeter of the triangle composed by the points p0, p1, and p2.
 
static ScalarType area (const PointT &p0, const PointT &p1, const PointT &p2)
 Computes the area of the triangle composed by the points p0, p1, and p2, considering that these three points are ordered in counterclockwise order.
 
static ScalarType quality (const PointT &p0, const PointT &p1, const PointT &p2)
 Calculates the quality measure of a triangle, given its three vertices.
 
static ScalarType qualityRadii (const PointT &p0, const PointT &p1, const PointT &p2)
 Compute a shape quality measure of the triangle composed by points p0, p1, p2.
 
static ScalarType qualityMeanRatio (const PointT &p0, const PointT &p1, const PointT &p2)
 Compute the mean ratio of a triangle shape quality measure.
 

Static Public Attributes

static const uint DIM = PointT::DIM
 

Private Attributes

std::array< PointT, 3 > mPoints
 

Member Function Documentation

◆ area() [1/2]

template<PointConcept PointT>
ScalarType vcl::Triangle< PointT >::area ( ) const
inline

Computes the area of the triangle.

Returns
The area of the triangle.

◆ area() [2/2]

template<PointConcept PointT>
static ScalarType vcl::Triangle< PointT >::area ( const PointT &  p0,
const PointT &  p1,
const PointT &  p2 
)
inlinestatic

Computes the area of the triangle composed by the points p0, p1, and p2, considering that these three points are ordered in counterclockwise order.

Parameters
[in]p0First point of the triangle.
[in]p1Second point of the triangle.
[in]p2Third point of the triangle.
Returns
The area of the triangle composed by p0, p1, and p2.

◆ barycenter() [1/2]

template<PointConcept PointT>
PointT vcl::Triangle< PointT >::barycenter ( ) const
inline

Computes the barycenter of the triangle.

Returns
The barycenter of the triangle.

◆ barycenter() [2/2]

template<PointConcept PointT>
static PointT vcl::Triangle< PointT >::barycenter ( const PointT &  p0,
const PointT &  p1,
const PointT &  p2 
)
inlinestatic

Computes the barycenter of the triangle composed by the points p0, p1, and p2.

Parameters
[in]p0first point of the triangle.
[in]p1second point of the triangle.
[in]p2third point of the triangle.
Returns
The barycenter of the triangle composed by p0, p1 and p2.

◆ barycentricCoordinatePoint() [1/2]

template<PointConcept PointT>
PointT vcl::Triangle< PointT >::barycentricCoordinatePoint ( const Point3< ScalarType > &  b) const
inline

Computes the point in the triangle with the given barycentric coordinates.

Given a set of barycentric coordinates b, this function computes the point in the triangle corresponding to those barycentric coordinates.

Parameters
[in]bThe barycentric coordinates of the point in the triangle of type Point3<ScalarType>.
Returns
The point in the triangle corresponding to the given barycentric coordinates.

◆ barycentricCoordinatePoint() [2/2]

template<PointConcept PointT>
static PointT vcl::Triangle< PointT >::barycentricCoordinatePoint ( const PointT &  p0,
const PointT &  p1,
const PointT &  p2,
ScalarType  b0,
ScalarType  b1,
ScalarType  b2 
)
inlinestatic

Computes the point in a triangle with the given barycentric coordinates.

Given a triangle with vertices p0, p1, and p2, and a set of barycentric coordinates b0, b1 and b2, this function computes the point in the triangle corresponding to those barycentric coordinates.

Parameters
[in]p0The first vertex of the triangle.
[in]p1The second vertex of the triangle.
[in]p2The third vertex of the triangle.
[in]b0The first barycentric coordinate of the point in the triangle.
[in]b1The first barycentric coordinate of the point in the triangle.
[in]b2The first barycentric coordinate of the point in the triangle.
Returns
The point in the triangle corresponding to the given barycentric coordinates.

◆ circumcenter() [1/2]

template<PointConcept PointT>
PointT vcl::Triangle< PointT >::circumcenter ( ) const
inline

Compute the circumcenter of the triangle.

The function computes the circumcenter of the triangle, which is the center of the circle that passes through the three vertices of the triangle. The circumcenter is defined as the intersection of the perpendicular bisectors of the three sides of the triangle.

Returns
The circumcenter of the triangle.
Note
The function assumes that the three points are not collinear and form a valid triangle.

◆ circumcenter() [2/2]

template<PointConcept PointT>
static PointT vcl::Triangle< PointT >::circumcenter ( const PointT &  p0,
const PointT &  p1,
const PointT &  p2 
)
inlinestatic

Compute the circumcenter of a triangle.

Given three points p0, p1, p2 representing a triangle, the function computes the circumcenter of the triangle, which is the center of the circle that passes through the three vertices of the triangle. The circumcenter is defined as the intersection of the perpendicular bisectors of the three sides of the triangle.

Template Parameters
PointTypeA type that satisfies the PointConcept.
Parameters
[in]p0The first point of the triangle.
[in]p1The second point of the triangle.
[in]p2The third point of the triangle.
Returns
The circumcenter of the triangle.
Note
The function assumes that the three points are not collinear and form a valid triangle.

◆ normal() [1/2]

template<PointConcept PointT>
PointT vcl::Triangle< PointT >::normal ( ) const
inline

Returns the normal of the triangle.

Note
This function is available only if the dimension of the triangle is 3.
Returns
The ormal of the triangle.

◆ normal() [2/2]

template<PointConcept PointT>
static PointT vcl::Triangle< PointT >::normal ( const PointT &  p0,
const PointT &  p1,
const PointT &  p2 
)
inlinestatic

Computes the normal of the triangle composed by the 3D points p0, p1, and p2, considering that these three points are ordered in counter-clockwise order.

Template Parameters
PointTypeA type that satisfies the PointConcept.
Parameters
[in]p0first point of the triangle.
[in]p1second point of the triangle.
[in]p2third point of the triangle.
Returns
The normal of the triangle composed by p0, p1 and p2.

◆ perimeter() [1/2]

template<PointConcept PointT>
ScalarType vcl::Triangle< PointT >::perimeter ( ) const
inline

Computes the perimeter of the triangle.

Returns
The perimeter of the triangle.

◆ perimeter() [2/2]

template<PointConcept PointT>
static ScalarType vcl::Triangle< PointT >::perimeter ( const PointT &  p0,
const PointT &  p1,
const PointT &  p2 
)
inlinestatic

Computes the perimeter of the triangle composed by the points p0, p1, and p2.

Parameters
[in]p0first point of the triangle.
[in]p1second point of the triangle.
[in]p2third point of the triangle.
Returns
The perimeter of the triangle composed by p0, p1, and p2.

◆ point()

template<PointConcept PointT>
const PointT & vcl::Triangle< PointT >::point ( uint  i) const
inline

Returns the i-th point of the triangle.

Parameters
[in]iIndex of the point to return.
Returns
The i-th point of the triangle.

◆ quality() [1/2]

template<PointConcept PointT>
ScalarType vcl::Triangle< PointT >::quality ( ) const
inline

Calculates the quality measure of the triangle.

The quality measure is computed as 2 times the triangle's area divided by the square of the length of its longest edge. The resulting value is in the range [0.0, 0.866], where 0.0 represents a degenerate triangle and 0.866 represents an equilateral triangle.

Returns
The quality measure of the triangle.
Note
If the area of the triangle is zero (i.e., the vertices are collinear), the function returns 0.0.

◆ quality() [2/2]

template<PointConcept PointT>
static ScalarType vcl::Triangle< PointT >::quality ( const PointT &  p0,
const PointT &  p1,
const PointT &  p2 
)
inlinestatic

Calculates the quality measure of a triangle, given its three vertices.

The quality measure is computed as 2 times the triangle's area divided by the square of the length of its longest edge. The resulting value is in the range [0.0, 0.866], where 0.0 represents a degenerate triangle and 0.866 represents an equilateral triangle.

Parameters
[in]p0The first vertex of the triangle.
[in]p1The second vertex of the triangle.
[in]p2The third vertex of the triangle.
Returns
The quality measure of the triangle.
Note
If the area of the triangle is zero (i.e., the vertices are collinear), the function returns 0.0.

◆ qualityMeanRatio() [1/2]

template<PointConcept PointT>
ScalarType vcl::Triangle< PointT >::qualityMeanRatio ( ) const
inline

Compute the mean ratio of the triangle shape quality measure.

The function computes the mean ratio shape quality measure of the triangle. The mean ratio is defined as 2 * sqrt(a * b) / (a + b), where a and b are the eigenvalues of the M^tM transformation matrix into a regular simplex. The mean ratio is a scalar value in the range [0, 1] that describes the triangle quality, where 0 means the triangle is degenerate, and 1 means it is perfectly equilateral.

Returns
The mean ratio shape quality measure of the triangle.
Note
If the three points are collinear or form a degenerate triangle, the function returns 0.

◆ qualityMeanRatio() [2/2]

template<PointConcept PointT>
static ScalarType vcl::Triangle< PointT >::qualityMeanRatio ( const PointT &  p0,
const PointT &  p1,
const PointT &  p2 
)
inlinestatic

Compute the mean ratio of a triangle shape quality measure.

Given three points p0, p1, p2 representing a triangle, the function computes the mean ratio shape quality measure of the triangle. The mean ratio is defined as 2 * sqrt(a * b) / (a + b), where a and b are the eigenvalues of the M^tM transformation matrix into a regular simplex. The mean ratio is a scalar value in the range [0, 1] that describes the triangle quality, where 0 means the triangle is degenerate, and 1 means it is perfectly equilateral.

Parameters
[in]p0The first point of the triangle.
[in]p1The second point of the triangle.
[in]p2The third point of the triangle.
Returns
The mean ratio shape quality measure of the triangle.
Note
The function assumes that the three points are not collinear and form a valid triangle. If the three points are collinear or form a degenerate triangle, the function returns 0.

◆ qualityRadii() [1/2]

template<PointConcept PointT>
ScalarType vcl::Triangle< PointT >::qualityRadii ( ) const
inline

Compute a shape quality measure of the triangle.

This function computes the quality measure of a triangle based on the ratio between its inradius and circumradius.

Returns
A value between 0 and 1 that represents the quality of the triangle shape. A value of 1 means the triangle is perfectly equilateral, while lower values indicate more distorted shapes (i.e., halfsquare: 0.81). A value of 0 is returned when the triangle is degenerate (i.e., it has zero area).

◆ qualityRadii() [2/2]

template<PointConcept PointT>
static ScalarType vcl::Triangle< PointT >::qualityRadii ( const PointT &  p0,
const PointT &  p1,
const PointT &  p2 
)
inlinestatic

Compute a shape quality measure of the triangle composed by points p0, p1, p2.

This function computes the quality measure of a triangle based on the ratio between its inradius and circumradius. The function takes three points (p0, p1, p2) representing the vertices of the triangle.

Parameters
[in]p0The first vertex of the triangle.
[in]p1The second vertex of the triangle.
[in]p2The third vertex of the triangle.
Returns
A value between 0 and 1 that represents the quality of the triangle shape. A value of 1 means the triangle is perfectly equilateral, while lower values indicate more distorted shapes (i.e., halfsquare: 0.81). A value of 0 is returned when the triangle is degenerate (i.e., it has zero area).

◆ sideLength() [1/2]

template<PointConcept PointT>
ScalarType vcl::Triangle< PointT >::sideLength ( const PointT &  p0,
const PointT &  p1,
const PointT &  p2,
uint  i 
) const
inline

Returns the length of the i-th side of the triangle composed by the points p0, p1, and p2.

Parameters
[in]p0first point of the triangle.
[in]p1second point of the triangle.
[in]p2third point of the triangle.
[in]iIndex of the side.
Returns
The length of the i-th side of the triangle.

◆ sideLength() [2/2]

template<PointConcept PointT>
ScalarType vcl::Triangle< PointT >::sideLength ( uint  i) const
inline

Returns the length of the i-th side of the triangle.

Parameters
[in]iIndex of the side.
Returns
The length of the i-th side of the triangle.

◆ sideLength0()

template<PointConcept PointT>
ScalarType vcl::Triangle< PointT >::sideLength0 ( ) const
inline

Returns the length of the first side of the triangle.

Returns
The length of the first side of the triangle.

◆ sideLength1()

template<PointConcept PointT>
ScalarType vcl::Triangle< PointT >::sideLength1 ( ) const
inline

Returns the length of the second side of the triangle.

Returns
The length of the second side of the triangle.

◆ sideLength2()

template<PointConcept PointT>
ScalarType vcl::Triangle< PointT >::sideLength2 ( ) const
inline

Returns the length of the third side of the triangle.

Returns
The length of the third side of the triangle.

◆ size()

template<PointConcept PointT>
constexpr uint vcl::Triangle< PointT >::size ( ) const
inlineconstexpr

Returns the number of points of the triangle.

Returns
3

◆ weightedBarycenter() [1/3]

template<PointConcept PointT>
PointT vcl::Triangle< PointT >::weightedBarycenter ( const Point3< ScalarType > &  w) const
inline

Computes the weighted barycenter of the triangle.

Given three weights corresponding to the three triangle points, this function computes the weighted barycenter of the triangle.

Parameters
[in]wThe weights of the three points of the triangle.
Returns
The weighted barycenter of the triangle.

◆ weightedBarycenter() [2/3]

template<PointConcept PointT>
static PointT vcl::Triangle< PointT >::weightedBarycenter ( const PointT &  p0,
const PointT &  p1,
const PointT &  p2,
ScalarType  w0,
ScalarType  w1,
ScalarType  w2 
)
inlinestatic

Computes the weighted barycenter of a triangle composed of three points.

Given three points and their corresponding weights, this function computes the weighted barycenter of the triangle they form.

Parameters
[in]p0The first point of the triangle.
[in]w0The weight of the first point of the triangle.
[in]p1The second point of the triangle.
[in]w1The weight of the second point of the triangle.
[in]p2The third point of the triangle.
[in]w2The weight of the third point of the triangle.
Returns
The weighted barycenter of the triangle formed by p0, p1 and p2.

◆ weightedBarycenter() [3/3]

template<PointConcept PointT>
PointT vcl::Triangle< PointT >::weightedBarycenter ( ScalarType  w0,
ScalarType  w1,
ScalarType  w2 
) const
inline

Computes the weighted barycenter of the triangle.

Given three weights corresponding to the three triangle points, this function computes the weighted barycenter of the triangle.

Parameters
[in]w0The weight of the first point of the triangle.
[in]w1The weight of the second point of the triangle.
[in]w2The weight of the third point of the triangle.
Returns
The weighted barycenter of the triangle.

The documentation for this class was generated from the following file: