MeshLib
 
Loading...
Searching...
No Matches
MR::TriPoint< T > Struct Template Reference

encodes a point inside a triangle using barycentric coordinates More...

#include <MRTriPoint.h>

Public Member Functions

constexpr TriPoint () noexcept
 
 TriPoint (NoInit) noexcept
 
constexpr TriPoint (T a, T b) noexcept
 
template<typename U >
constexpr TriPoint (const TriPoint< U > &s)
 
 TriPoint (const Vector3< T > &p, const Vector3< T > &v0, const Vector3< T > &v1, const Vector3< T > &v2)
 given a point coordinates and triangle (v0,v1,v2) computes barycentric coordinates of the point
 
 TriPoint (const Vector3< T > &p, const Vector3< T > &v1, const Vector3< T > &v2)
 given a point coordinates and triangle (0,v1,v2) computes barycentric coordinates of the point
 
template<typename U >
interpolate (const U &v0, const U &v1, const U &v2) const
 given three values in three vertices, computes interpolated value at this barycentric coordinates
 
TriPoint lnext () const
 represents the same point relative to next edge in the same triangle
 
constexpr int inVertex () const
 returns [0,2] if the point is in a vertex or -1 otherwise
 
constexpr int onEdge () const
 
constexpr bool operator== (const TriPoint &rhs) const =default
 returns true if two points have equal (a,b) representation
 

Public Attributes

a
 a in [0,1], a=0 => point is on [v2,v0] edge, a=1 => point is in v1
 
b
 b in [0,1], b=0 => point is on [v0,v1] edge, b=1 => point is in v2
 

Static Public Attributes

static constexpr auto eps = SegmPoint<T>::eps
 

Detailed Description

template<typename T>
struct MR::TriPoint< T >

encodes a point inside a triangle using barycentric coordinates

Notations used below: v0, v1, v2 - points of the triangle

Constructor & Destructor Documentation

◆ TriPoint() [1/6]

template<typename T >
MR::TriPoint< T >::TriPoint ( )
inlineconstexprnoexcept

◆ TriPoint() [2/6]

template<typename T >
MR::TriPoint< T >::TriPoint ( NoInit )
inlineexplicitnoexcept

◆ TriPoint() [3/6]

template<typename T >
MR::TriPoint< T >::TriPoint ( T a,
T b )
inlineconstexprnoexcept

◆ TriPoint() [4/6]

template<typename T >
template<typename U >
MR::TriPoint< T >::TriPoint ( const TriPoint< U > & s)
inlineconstexpr

◆ TriPoint() [5/6]

template<typename T >
MR::TriPoint< T >::TriPoint ( const Vector3< T > & p,
const Vector3< T > & v0,
const Vector3< T > & v1,
const Vector3< T > & v2 )
inline

given a point coordinates and triangle (v0,v1,v2) computes barycentric coordinates of the point

◆ TriPoint() [6/6]

template<typename T >
MR::TriPoint< T >::TriPoint ( const Vector3< T > & p,
const Vector3< T > & v1,
const Vector3< T > & v2 )

given a point coordinates and triangle (0,v1,v2) computes barycentric coordinates of the point

Member Function Documentation

◆ interpolate()

template<typename T >
template<typename U >
U MR::TriPoint< T >::interpolate ( const U & v0,
const U & v1,
const U & v2 ) const
inline

given three values in three vertices, computes interpolated value at this barycentric coordinates

◆ inVertex()

template<typename T >
int MR::TriPoint< T >::inVertex ( ) const
constexpr

returns [0,2] if the point is in a vertex or -1 otherwise

◆ lnext()

template<typename T >
TriPoint MR::TriPoint< T >::lnext ( ) const
inlinenodiscard

represents the same point relative to next edge in the same triangle

◆ onEdge()

template<typename T >
int MR::TriPoint< T >::onEdge ( ) const
constexpr

returns [0,2] if the point is on edge or -1 otherwise: 0 means edge [v1,v2]; 1 means edge [v2,v0]; 2 means edge [v0,v1]

◆ operator==()

template<typename T >
bool MR::TriPoint< T >::operator== ( const TriPoint< T > & rhs) const
nodiscardconstexprdefault

returns true if two points have equal (a,b) representation

Member Data Documentation

◆ a

template<typename T >
T MR::TriPoint< T >::a

a in [0,1], a=0 => point is on [v2,v0] edge, a=1 => point is in v1

barycentric coordinates: a+b in [0,1], a+b=0 => point is in v0, a+b=1 => point is on [v1,v2] edge

◆ b

template<typename T >
T MR::TriPoint< T >::b

b in [0,1], b=0 => point is on [v0,v1] edge, b=1 => point is in v2

◆ eps

template<typename T >
auto MR::TriPoint< T >::eps = SegmPoint<T>::eps
staticconstexpr

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