DGtal 1.4.0
Loading...
Searching...
No Matches
DGtal::NormalCycleFormula< TRealPoint, TRealVector > Struct Template Reference

Aim: A helper class that provides static methods to compute normal cycle formulas of curvatures. More...

#include <DGtal/geometry/meshes/NormalCycleFormula.h>

Public Types

typedef TRealPoint RealPoint
 
typedef TRealVector RealVector
 
typedef RealVector::Component Scalar
 
typedef std::vector< RealPointRealPoints
 
typedef std::vector< RealVectorRealVectors
 
typedef SimpleMatrix< Scalar, 3, 3 > RealTensor
 
typedef std::size_t Size
 
typedef std::size_t Index
 

Static Public Member Functions

Formulas for curvature
static Scalar area (const RealPoints &pts)
 
static Scalar twiceMeanCurvature (const RealPoint &a, const RealPoint &b, const RealVector &right, const RealVector &left)
 
static Scalar gaussianCurvature (const RealPoint &a, const RealPoints &vtcs)
 
static Scalar gaussianCurvatureWithPairs (const RealPoint &a, const RealPoints &pairs)
 
static RealTensor anisotropicCurvatureH1 (const RealPoint &a, const RealPoint &b, const RealVector &right, const RealVector &left)
 
static RealTensor anisotropicCurvatureH2 (const RealPoint &a, const RealPoint &b, const RealVector &right, const RealVector &left)
 
Other geometric services
static RealPoint barycenter (const RealPoints &pts)
 
static RealVector normal (const RealPoint &a, const RealPoint &b, const RealPoint &c)
 
static Scalar area (const RealPoint &a, const RealPoint &b, const RealPoint &c)
 
static RealVector averageUnitVector (const RealVectors &vecs)
 

Static Public Attributes

static const Dimension dimension = RealPoint::dimension
 

Detailed Description

template<typename TRealPoint, typename TRealVector>
struct DGtal::NormalCycleFormula< TRealPoint, TRealVector >

Aim: A helper class that provides static methods to compute normal cycle formulas of curvatures.

Description of class 'NormalCycleFormula'

Template Parameters
TRealPointany model of 3D RealPoint.
TRealVectorany model of 3D RealVector.

Definition at line 64 of file NormalCycleFormula.h.

Member Typedef Documentation

◆ Index

template<typename TRealPoint , typename TRealVector >
typedef std::size_t DGtal::NormalCycleFormula< TRealPoint, TRealVector >::Index

Definition at line 73 of file NormalCycleFormula.h.

◆ RealPoint

template<typename TRealPoint , typename TRealVector >
typedef TRealPoint DGtal::NormalCycleFormula< TRealPoint, TRealVector >::RealPoint

Definition at line 66 of file NormalCycleFormula.h.

◆ RealPoints

template<typename TRealPoint , typename TRealVector >
typedef std::vector< RealPoint > DGtal::NormalCycleFormula< TRealPoint, TRealVector >::RealPoints

Definition at line 69 of file NormalCycleFormula.h.

◆ RealTensor

template<typename TRealPoint , typename TRealVector >
typedef SimpleMatrix< Scalar, 3, 3 > DGtal::NormalCycleFormula< TRealPoint, TRealVector >::RealTensor

Definition at line 71 of file NormalCycleFormula.h.

◆ RealVector

template<typename TRealPoint , typename TRealVector >
typedef TRealVector DGtal::NormalCycleFormula< TRealPoint, TRealVector >::RealVector

Definition at line 67 of file NormalCycleFormula.h.

◆ RealVectors

template<typename TRealPoint , typename TRealVector >
typedef std::vector< RealVector > DGtal::NormalCycleFormula< TRealPoint, TRealVector >::RealVectors

Definition at line 70 of file NormalCycleFormula.h.

◆ Scalar

template<typename TRealPoint , typename TRealVector >
typedef RealVector::Component DGtal::NormalCycleFormula< TRealPoint, TRealVector >::Scalar

Definition at line 68 of file NormalCycleFormula.h.

◆ Size

template<typename TRealPoint , typename TRealVector >
typedef std::size_t DGtal::NormalCycleFormula< TRealPoint, TRealVector >::Size

Definition at line 72 of file NormalCycleFormula.h.

Member Function Documentation

◆ anisotropicCurvatureH1()

template<typename TRealPoint , typename TRealVector >
static RealTensor DGtal::NormalCycleFormula< TRealPoint, TRealVector >::anisotropicCurvatureH1 ( const RealPoint & a,
const RealPoint & b,
const RealVector & right,
const RealVector & left )
inlinestatic

Computes the anisotropic measure \( \bar{H} \) at edge ab.

Parameters
aany point
bany point
rightthe normal vector at face xba where x is some vertex(ices)
leftthe normal vector at face yab where y is some vertex(ices)
Returns
the anisotropic curvature measure \( \bar{H} \) at edge ab.

Definition at line 159 of file NormalCycleFormula.h.

162 {
163 const RealVector diedre = right.crossProduct( left );
164 const Scalar length = std::max( 0.0, std::min( 1.0, diedre.norm() ) );
165 const Scalar angle = ( diedre.dot( b - a) > 0.0 )
166 ? asin( length ) : - asin( length );
167 RealVector e_p = right + left;
168 RealVector e_m = right - left;
169 const Scalar norm_e_p = e_p.norm();
170 const Scalar norm_e_m = e_m.norm();
171 e_p = norm_e_p > 1e-10 ? e_p / norm_e_p : RealVector::zero;
172 e_m = norm_e_m > 1e-10 ? e_m / norm_e_m : RealVector::zero;
173 const RealTensor T_p =
174 { e_p[ 0 ] * e_p[ 0 ], e_p[ 0 ] * e_p[ 1 ], e_p[ 0 ] * e_p[ 2 ],
175 e_p[ 1 ] * e_p[ 0 ], e_p[ 1 ] * e_p[ 1 ], e_p[ 1 ] * e_p[ 2 ],
176 e_p[ 2 ] * e_p[ 0 ], e_p[ 2 ] * e_p[ 1 ], e_p[ 2 ] * e_p[ 2 ] };
177 const RealTensor T_m =
178 { e_m[ 0 ] * e_m[ 0 ], e_m[ 0 ] * e_m[ 1 ], e_m[ 0 ] * e_m[ 2 ],
179 e_m[ 1 ] * e_m[ 0 ], e_m[ 1 ] * e_m[ 1 ], e_m[ 1 ] * e_m[ 2 ],
180 e_m[ 2 ] * e_m[ 0 ], e_m[ 2 ] * e_m[ 1 ], e_m[ 2 ] * e_m[ 2 ] };
181 return 0.5 * ( b - a ).norm()
182 * ( ( angle - sin( angle ) ) * T_p + ( angle + sin( angle ) ) * T_m );
183 }
static Self zero
Static const for zero PointVector.
SimpleMatrix< Scalar, 3, 3 > RealTensor

References DGtal::PointVector< dim, TEuclideanRing, TContainer >::zero.

◆ anisotropicCurvatureH2()

template<typename TRealPoint , typename TRealVector >
static RealTensor DGtal::NormalCycleFormula< TRealPoint, TRealVector >::anisotropicCurvatureH2 ( const RealPoint & a,
const RealPoint & b,
const RealVector & right,
const RealVector & left )
inlinestatic

Computes the anisotropic measure \( \bar{\tilde{H}} \) at edge ab.

Parameters
aany point
bany point
rightthe normal vector at face xba where x is some vertex(ices)
leftthe normal vector at face yab where y is some vertex(ices)
Returns
the anisotropic curvature measure \( \bar{\tilde{H}} \) at edge ab.

Definition at line 192 of file NormalCycleFormula.h.

195 {
196 const RealVector diedre = right.crossProduct( left );
197 const Scalar length = std::max( 0.0, std::min( 1.0, diedre.norm() ) );
198 const Scalar angle = ( diedre.dot( b - a) > 0.0 )
199 ? asin( length ) : - asin( length );
200 const Scalar norm_ab = (b - a).norm();
201 const RealVector e = norm_ab > 1e-10 ? (b - a) / norm_ab : RealVector::zero;
202 const RealTensor T =
203 { e[ 0 ] * e[ 0 ], e[ 0 ] * e[ 1 ], e[ 0 ] * e[ 2 ],
204 e[ 1 ] * e[ 0 ], e[ 1 ] * e[ 1 ], e[ 1 ] * e[ 2 ],
205 e[ 2 ] * e[ 0 ], e[ 2 ] * e[ 1 ], e[ 2 ] * e[ 2 ] };
206 return ( 0.5 * norm_ab * angle ) * T; // JOL * 0.5
207 }

References DGtal::PointVector< dim, TEuclideanRing, TContainer >::zero.

◆ area() [1/2]

template<typename TRealPoint , typename TRealVector >
static Scalar DGtal::NormalCycleFormula< TRealPoint, TRealVector >::area ( const RealPoint & a,
const RealPoint & b,
const RealPoint & c )
inlinestatic

Computes triangle area

Parameters
aany point
bany point
cany point
Returns
the area of triangle abc

Definition at line 245 of file NormalCycleFormula.h.

246 {
247 return 0.5 * ( ( b - a ).crossProduct( c - a ) ).norm();
248 }
auto crossProduct(PointVector< 3, LeftEuclideanRing, LeftContainer > const &lhs, PointVector< 3, RightEuclideanRing, RightContainer > const &rhs) -> decltype(DGtal::constructFromArithmeticConversion(lhs, rhs))
Cross product of two 3D Points/Vectors.

References DGtal::crossProduct().

◆ area() [2/2]

template<typename TRealPoint , typename TRealVector >
static Scalar DGtal::NormalCycleFormula< TRealPoint, TRealVector >::area ( const RealPoints & pts)
inlinestatic

Computes area of polygonal face pts.

Parameters
ptsthe (ccw ordered) points forming the vertices of a polygonal face.
Returns
the area of the given polygonal face.

Definition at line 85 of file NormalCycleFormula.h.

86 {
87 if ( pts.size() < 3 ) return 0.0;
88 if ( pts.size() == 3 )
89 return area( pts[ 0 ], pts[ 1 ], pts[ 2 ] );
90 const RealPoint b = barycenter( pts );
91 Scalar a = 0.0;
92 for ( Index i = 0; i < pts.size(); i++ )
93 a += area( b, pts[ i ], pts[ (i+1)%pts.size() ] );
94 return a;
95 }
SMesh::Index Index
static Scalar area(const RealPoints &pts)
static RealPoint barycenter(const RealPoints &pts)
PointVector< 3, double > RealPoint

References DGtal::NormalCycleFormula< TRealPoint, TRealVector >::area(), and DGtal::NormalCycleFormula< TRealPoint, TRealVector >::barycenter().

Referenced by DGtal::NormalCycleFormula< TRealPoint, TRealVector >::area().

◆ averageUnitVector()

template<typename TRealPoint , typename TRealVector >
static RealVector DGtal::NormalCycleFormula< TRealPoint, TRealVector >::averageUnitVector ( const RealVectors & vecs)
inlinestatic

Given a vector of unit vectors, returns their average unit vector.

Parameters
vecsany vector of vectors.
Returns
the average unit vector.

Definition at line 254 of file NormalCycleFormula.h.

255 {
256 RealVector avg;
257 for ( auto v : vecs ) avg += v;
258 auto avg_norm = avg.norm();
259 return avg_norm != 0.0 ? avg / avg_norm : avg;
260 }

◆ barycenter()

template<typename TRealPoint , typename TRealVector >
static RealPoint DGtal::NormalCycleFormula< TRealPoint, TRealVector >::barycenter ( const RealPoints & pts)
inlinestatic

Given a vector of points, returns its barycenter.

Parameters
ptsany vector of points
Returns
the barycenter of these points.

Definition at line 219 of file NormalCycleFormula.h.

220 {
221 RealPoint b;
222 for ( auto p : pts ) b += p;
223 b /= pts.size();
224 return b;
225 }

Referenced by DGtal::NormalCycleFormula< TRealPoint, TRealVector >::area().

◆ gaussianCurvature()

template<typename TRealPoint , typename TRealVector >
static Scalar DGtal::NormalCycleFormula< TRealPoint, TRealVector >::gaussianCurvature ( const RealPoint & a,
const RealPoints & vtcs )
inlinestatic

Computes the Gaussian curvature at point a with incident vertices vtcs.

Parameters
aany point
vtcsa range of points
Returns
the Gaussian curvature according to Normal Cycle formula.

Definition at line 124 of file NormalCycleFormula.h.

126 {
127 Scalar angle_sum = 0.0;
128 for ( Size i = 0; i < vtcs.size(); i++ )
129 angle_sum += acos( (vtcs[i] - a).getNormalized()
130 .dot( ( vtcs[(i+1)%vtcs.size()] - a ).getNormalized() ) );
131 return 2.0 * M_PI - angle_sum;
132 }
HalfEdgeDataStructure::Size Size

◆ gaussianCurvatureWithPairs()

template<typename TRealPoint , typename TRealVector >
static Scalar DGtal::NormalCycleFormula< TRealPoint, TRealVector >::gaussianCurvatureWithPairs ( const RealPoint & a,
const RealPoints & pairs )
inlinestatic

Computes the Gaussian curvature at point a with incident pairs of points pairs.

Parameters
aany point
pairsa range of points [x_0, y_0, x_1, y_1, etc] such that (a,x_i,y_i) is an incident face to a.
Returns
the Gaussian curvature according to Normal Cycle formula.

Definition at line 142 of file NormalCycleFormula.h.

144 {
145 Scalar angle_sum = 0.0;
146 for ( Size i = 0; i < pairs.size(); i += 2 )
147 angle_sum += acos( ( pairs[i] - a ).getNormalized()
148 .dot( ( pairs[i+1] - a ).getNormalized() ) );
149 return 2.0 * M_PI - angle_sum;
150 }

◆ normal()

template<typename TRealPoint , typename TRealVector >
static RealVector DGtal::NormalCycleFormula< TRealPoint, TRealVector >::normal ( const RealPoint & a,
const RealPoint & b,
const RealPoint & c )
inlinestatic

Computes a unit normal vector to triangle abc

Parameters
aany point
bany point
cany point
Returns
the unit normal vector to abc, ( ab x ac ) / || ab x ac ||.

Definition at line 234 of file NormalCycleFormula.h.

235 {
236 return ( ( b - a ).crossProduct( c - a ) ).getNormalized();
237 }

References DGtal::crossProduct().

◆ twiceMeanCurvature()

template<typename TRealPoint , typename TRealVector >
static Scalar DGtal::NormalCycleFormula< TRealPoint, TRealVector >::twiceMeanCurvature ( const RealPoint & a,
const RealPoint & b,
const RealVector & right,
const RealVector & left )
inlinestatic

Computes twice the mean curvature on edge ab given normal vectors right, left.

Parameters
aany point
bany point
rightthe normal vector at face xba where x is some vertex(ices)
leftthe normal vector at face yab where y is some vertex(ices)
Returns
twice the mean curvature according to Normal Cycle formula.

Definition at line 106 of file NormalCycleFormula.h.

109 {
110 const RealVector diedre = right.crossProduct( left );
111 const Scalar n = std::min( 1.0, std::max( diedre.norm(), 0.0 ) );
112 const Scalar angle = ( diedre.dot( b - a) < 0.0 )
113 ? asin( n ) : - asin( n );
114 return ( b - a ).norm() * angle;
115 }

Field Documentation

◆ dimension

template<typename TRealPoint , typename TRealVector >
const Dimension DGtal::NormalCycleFormula< TRealPoint, TRealVector >::dimension = RealPoint::dimension
static

Definition at line 74 of file NormalCycleFormula.h.


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