Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::math::TBasicTriangle< T > Class Template Reference

Basic 3-D triangle functionalities. More...

#include <TBasicTriangle.h>

Inheritance diagram for ph::math::TBasicTriangle< T >:
ph::math::TTriangle< T > ph::math::TWatertightTriangle< T >

Public Member Functions

 TBasicTriangle (TVector3< T > vA, TVector3< T > vB, TVector3< T > vC)
 
 TBasicTriangle (std::array< TVector3< T >, 3 > vertices)
 
getArea () const
 
TVector3< T > getFaceNormal () const
 
TVector3< T > getCentroid () const
 
TAABB3D< T > getAABB () const
 
getAspectRatio () const
 Calculate aspect ratio of this triangle. For a triangle, its aspect ratio is defined to be the ratio of the circumradius to twice the inradius. The higher the aspect ratio, the narrower the shape of the triangle. A triangle with extreme aspect ratio will look like a needle. The smallest aspect ratio possible is 1 (an equilateral triangle), while the largest possible aspect ratio is infinity (degenerate).
 
TVector3< T > safeGetFaceNormal (const TVector3< T > &failSafe={0, 1, 0}) const
 Calculate face normal with a fail-safe value. The vertices may form a degenerate triangle (zero cross product and thus producing NaNs after being normalized, or vertices with Inf/NaN), in such case the fail-safe vector will be returned.
 
std::pair< TVector3< T >, TVector3< T > > getEdgeVectors () const
 
TVector3< T > surfaceToBarycentric (const TVector3< T > &position) const
 
TVector3< T > barycentricToSurface (const TVector3< T > &barycentricCoords) const
 
TVector3< T > sampleToBarycentricOsada (const std::array< T, 2 > &sample) const
 Map the 2D sample to a position on the surface of the triangle. A common mapping on triangles which is based on slicing the triangular area into stripes. The mapped positions (after being converted from barycentric coordinates) are distributed uniformly if the sample is uniform. Reference: Osada et al., Section 4.2, "Shape Distributions", TOG02.
 
TVector3< T > sampleToBarycentricOsada (const std::array< T, 2 > &sample, T *out_pdfA) const
 
uniformSurfaceSamplePdfA () const
 
bool isDegenerate () const
 
TVector3< T > getVa () const
 
TVector3< T > getVb () const
 
TVector3< T > getVc () const
 

Static Public Member Functions

static TVector3< T > interpolate (const std::array< TVector3< T >, 3 > &attributes, const TVector3< T > &barycentricCoords)
 
static TVector3< T > interpolate (const TVector3< T > &attributeA, const TVector3< T > &attributeB, const TVector3< T > &attributeC, const TVector3< T > &barycentricCoords)
 
static bool calcSurfaceParamDerivatives (const std::array< TVector3< T >, 3 > &attributes, const std::array< TVector2< T >, 3 > &parameterizations, TVector3< T > *out_dXdU, TVector3< T > *out_dXdV)
 

Protected Member Functions

 PH_DEFINE_INLINE_RULE_OF_5_MEMBERS (TBasicTriangle)
 

Detailed Description

template<typename T>
class ph::math::TBasicTriangle< T >

Basic 3-D triangle functionalities.

The class is not intended to be used polymorphically.

Constructor & Destructor Documentation

◆ TBasicTriangle() [1/2]

template<typename T >
ph::math::TBasicTriangle< T >::TBasicTriangle ( TVector3< T > vA,
TVector3< T > vB,
TVector3< T > vC )
inline

◆ TBasicTriangle() [2/2]

template<typename T >
ph::math::TBasicTriangle< T >::TBasicTriangle ( std::array< TVector3< T >, 3 > vertices)
inlineexplicit

Member Function Documentation

◆ barycentricToSurface()

template<typename T >
TVector3< T > ph::math::TBasicTriangle< T >::barycentricToSurface ( const TVector3< T > & barycentricCoords) const
inline

◆ calcSurfaceParamDerivatives()

template<typename T >
bool ph::math::TBasicTriangle< T >::calcSurfaceParamDerivatives ( const std::array< TVector3< T >, 3 > & attributes,
const std::array< TVector2< T >, 3 > & parameterizations,
TVector3< T > * out_dXdU,
TVector3< T > * out_dXdV )
inlinestatic

◆ getAABB()

template<typename T >
TAABB3D< T > ph::math::TBasicTriangle< T >::getAABB ( ) const
inline

◆ getArea()

template<typename T >
T ph::math::TBasicTriangle< T >::getArea ( ) const
inline

◆ getAspectRatio()

template<typename T >
T ph::math::TBasicTriangle< T >::getAspectRatio ( ) const
inline

Calculate aspect ratio of this triangle. For a triangle, its aspect ratio is defined to be the ratio of the circumradius to twice the inradius. The higher the aspect ratio, the narrower the shape of the triangle. A triangle with extreme aspect ratio will look like a needle. The smallest aspect ratio possible is 1 (an equilateral triangle), while the largest possible aspect ratio is infinity (degenerate).

Note
For integer types, returns 0 for degenerate triangles.

◆ getCentroid()

template<typename T >
TVector3< T > ph::math::TBasicTriangle< T >::getCentroid ( ) const
inline

◆ getEdgeVectors()

template<typename T >
std::pair< TVector3< T >, TVector3< T > > ph::math::TBasicTriangle< T >::getEdgeVectors ( ) const
inline

◆ getFaceNormal()

template<typename T >
TVector3< T > ph::math::TBasicTriangle< T >::getFaceNormal ( ) const
inline

◆ getVa()

template<typename T >
TVector3< T > ph::math::TBasicTriangle< T >::getVa ( ) const
inline

◆ getVb()

template<typename T >
TVector3< T > ph::math::TBasicTriangle< T >::getVb ( ) const
inline

◆ getVc()

template<typename T >
TVector3< T > ph::math::TBasicTriangle< T >::getVc ( ) const
inline

◆ interpolate() [1/2]

template<typename T >
TVector3< T > ph::math::TBasicTriangle< T >::interpolate ( const std::array< TVector3< T >, 3 > & attributes,
const TVector3< T > & barycentricCoords )
inlinestatic

◆ interpolate() [2/2]

template<typename T >
TVector3< T > ph::math::TBasicTriangle< T >::interpolate ( const TVector3< T > & attributeA,
const TVector3< T > & attributeB,
const TVector3< T > & attributeC,
const TVector3< T > & barycentricCoords )
inlinestatic

◆ isDegenerate()

template<typename T >
bool ph::math::TBasicTriangle< T >::isDegenerate ( ) const
inline
Returns
Whether the triangle is a point, line, or contains non-finite vertices.

◆ PH_DEFINE_INLINE_RULE_OF_5_MEMBERS()

template<typename T >
ph::math::TBasicTriangle< T >::PH_DEFINE_INLINE_RULE_OF_5_MEMBERS ( TBasicTriangle< T > )
protected

◆ safeGetFaceNormal()

template<typename T >
TVector3< T > ph::math::TBasicTriangle< T >::safeGetFaceNormal ( const TVector3< T > & failSafe = {0, 1, 0}) const
inline

Calculate face normal with a fail-safe value. The vertices may form a degenerate triangle (zero cross product and thus producing NaNs after being normalized, or vertices with Inf/NaN), in such case the fail-safe vector will be returned.

Parameters
failSafeThe value to use when the face normal cannot be obtained.
Returns
The face normal. Potentially being failSafe.

◆ sampleToBarycentricOsada() [1/2]

template<typename T >
TVector3< T > ph::math::TBasicTriangle< T >::sampleToBarycentricOsada ( const std::array< T, 2 > & sample) const
inline

Map the 2D sample to a position on the surface of the triangle. A common mapping on triangles which is based on slicing the triangular area into stripes. The mapped positions (after being converted from barycentric coordinates) are distributed uniformly if the sample is uniform. Reference: Osada et al., Section 4.2, "Shape Distributions", TOG02.

Returns
Sampled barycentric coordinates.

◆ sampleToBarycentricOsada() [2/2]

template<typename T >
TVector3< T > ph::math::TBasicTriangle< T >::sampleToBarycentricOsada ( const std::array< T, 2 > & sample,
T * out_pdfA ) const
inline

An overload with PDF. Expected the input sample to be uniform.

◆ surfaceToBarycentric()

template<typename T >
TVector3< T > ph::math::TBasicTriangle< T >::surfaceToBarycentric ( const TVector3< T > & position) const
inline

◆ uniformSurfaceSamplePdfA()

template<typename T >
T ph::math::TBasicTriangle< T >::uniformSurfaceSamplePdfA ( ) const
inline

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