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

The TriangleWrapper class is a wrapper around a N-Dimensional triangle. More...

#include <vclib/space/core/triangle_wrapper.h>

Public Types

using ScalarType = PointT::ScalarType
 
using PointType = PointT
 

Public Member Functions

 TriangleWrapper (const PointT &p0, const PointT &p1, const PointT &p2)
 Constructs a triangle wrapper around the three input points.
 
constexpr uint size () const
 Returns the number of points of the triangle.
 
const PointT & point (uint i) const
 
const PointT & point0 () const
 
const PointT & point1 () const
 
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
 
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.
 

Static Public Attributes

static const uint DIM = PointT::DIM
 Dimension of the triangle.
 

Private Attributes

const PointT & mPoint0
 
const PointT & mPoint1
 
const PointT & mPoint2
 

Detailed Description

template<PointConcept PointT>
class vcl::TriangleWrapper< PointT >

The TriangleWrapper class is a wrapper around a N-Dimensional triangle.

The dimension of the triangle is determined by the dimension of the points it is composed of.

The class does not store the triangle points, but it provides a wrapper around them. This class is useful when the triangle points are already stored somewhere else and the user does not want to copy them, but have access to the a triangle interface.

This means that the TriangleWrapper object must live as long as the points it wraps. If the points are destroyed, the TriangleWrapper object becomes invalid.

This class cannot be copied or moved, and has just one constructor that takes three points as input. The points are passed by const reference, and their references are stored inside the class.

Constructor & Destructor Documentation

◆ TriangleWrapper()

template<PointConcept PointT>
vcl::TriangleWrapper< PointT >::TriangleWrapper ( const PointT &  p0,
const PointT &  p1,
const PointT &  p2 
)
inline

Constructs a triangle wrapper around the three input points.

The input points are not copied, and this class just stores their references.

Parameters
[in]p0first point of the triangle.
[in]p1second point of the triangle.
[in]p2third point of the triangle.

Member Function Documentation

◆ area()

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

Computes the area of the triangle.

Returns
The area of the triangle.

◆ barycenter()

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

Computes the barycenter of the triangle.

Returns
The barycenter of the triangle.

◆ barycentricCoordinatePoint() [1/2]

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

◆ barycentricCoordinatePoint() [2/2]

template<PointConcept PointT>
PointT vcl::TriangleWrapper< PointT >::barycentricCoordinatePoint ( ScalarType  b0,
ScalarType  b1,
ScalarType  b2 
) const
inline

◆ circumcenter()

template<PointConcept PointT>
PointT vcl::TriangleWrapper< 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.

◆ normal()

template<PointConcept PointT>
PointT vcl::TriangleWrapper< 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.

◆ perimeter()

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

Computes the perimeter of the triangle.

Returns
The perimeter of the triangle.

◆ point()

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

◆ point0()

template<PointConcept PointT>
const PointT & vcl::TriangleWrapper< PointT >::point0 ( ) const
inline

◆ point1()

template<PointConcept PointT>
const PointT & vcl::TriangleWrapper< PointT >::point1 ( ) const
inline

◆ point2()

template<PointConcept PointT>
const PointT & vcl::TriangleWrapper< PointT >::point2 ( ) const
inline

◆ quality()

template<PointConcept PointT>
ScalarType vcl::TriangleWrapper< 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.

◆ qualityMeanRatio()

template<PointConcept PointT>
ScalarType vcl::TriangleWrapper< 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.

◆ qualityRadii()

template<PointConcept PointT>
ScalarType vcl::TriangleWrapper< 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).

◆ sideLength()

template<PointConcept PointT>
ScalarType vcl::TriangleWrapper< 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::TriangleWrapper< 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::TriangleWrapper< 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::TriangleWrapper< 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::TriangleWrapper< PointT >::size ( ) const
inlineconstexpr

Returns the number of points of the triangle.

Returns
3

◆ weightedBarycenter() [1/2]

template<PointConcept PointT>
PointT vcl::TriangleWrapper< 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]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.

◆ weightedBarycenter() [2/2]

template<PointConcept PointT>
PointT vcl::TriangleWrapper< 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: