31#if defined(NormalCycleFormula_RECURSES)
32#error Recursive header files inclusion detected in NormalCycleFormula.h
35#define NormalCycleFormula_RECURSES
37#if !defined NormalCycleFormula_h
39#define NormalCycleFormula_h
45#include "DGtal/base/Common.h"
46#include "DGtal/math/linalg/SimpleMatrix.h"
63 template <
typename TRealPo
int,
typename TRealVector >
87 if ( pts.size() < 3 )
return 0.0;
88 if ( pts.size() == 3 )
89 return area( pts[ 0 ], pts[ 1 ], pts[ 2 ] );
92 for (
Index i = 0; i < pts.size(); i++ )
93 a +=
area( b, pts[ i ], pts[ (i+1)%pts.size() ] );
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;
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;
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;
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 );
169 const Scalar norm_e_p = e_p.norm();
170 const Scalar norm_e_m = e_m.norm();
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 ] };
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 );
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();
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;
222 for (
auto p : pts ) b += p;
236 return ( ( b - a ).
crossProduct( c - a ) ).getNormalized();
247 return 0.5 * ( ( b - a ).
crossProduct( c - a ) ).norm();
257 for (
auto v : vecs ) avg += v;
258 auto avg_norm = avg.norm();
259 return avg_norm != 0.0 ? avg / avg_norm : avg;
279#undef NormalCycleFormula_RECURSES
TEuclideanRing Component
Type for Vector elements.
static Self zero
Static const for zero PointVector.
static const Dimension dimension
Copy of the static dimension of the Point/Vector.
Aim: implements basic MxN Matrix services (M,N>=1).
DGtal is the top-level namespace which contains all DGtal functions and types.
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.
DGtal::uint32_t Dimension