31 #if defined(SphericalTriangle_RECURSES)
32 #error Recursive header files inclusion detected in SphericalTriangle.h
33 #else // defined(SphericalTriangle_RECURSES)
35 #define SphericalTriangle_RECURSES
37 #if !defined SphericalTriangle_h
39 #define SphericalTriangle_h
45 #include "DGtal/base/Common.h"
60 template <
typename TSpace>
83 bool normalize =
true )
85 setA( va, normalize );
86 setB( vb, normalize );
87 setC( vc, normalize );
121 if ( fabs( n ) > 1e-8 )
myA /= n;
137 if ( fabs( n ) > 1e-8 )
myB /= n;
152 if ( fabs( n ) > 1e-8 )
myC /= n;
164 if ( ( d[ 0 ] < 1e-8 ) || ( d[ 1 ] < 1e-8 ) || ( d[ 2 ] < 1e-8 ) )
168 if ( d[ 1 ] > d[ m ] ) m = 1;
169 if ( d[ 2 ] > d[ m ] ) m = 2;
170 return ( fabs( d[ m ] - d[ (m+1)%3 ] - d[ (m+2)%3 ] ) < 1e-8 );
180 if ( Ap.dot(
myA ) < 0.0 ) Ap = -Ap;
181 if ( Bp.dot(
myB ) < 0.0 ) Bp = -Bp;
182 if ( Cp.dot(
myC ) < 0.0 ) Cp = -Cp;
183 return Self( Ap, Bp, Cp,
true );
194 alpha = beta = gamma = 0.0;
209 Scalar alpha, beta, gamma;
212 return ( (alpha == 0.0) || (beta == 0.0) || (gamma == 0.0) )
213 ? 0.0 : 2.0*M_PI - alpha - beta - gamma;
222 if ( M.
norm1() <= 1e-8 || X.
norm1() <= 1e-8 )
return 0.0;
223 return M.
dot( X ) < 0.0 ? -S : S;
252 #endif // !defined SphericalTriangle_h
254 #undef SphericalTriangle_RECURSES
255 #endif // else defined(SphericalTriangle_RECURSES)
void setA(const RealVector &va, bool normalize=true)
Aim: Represent a triangle drawn onto a sphere of radius 1.
SphericalTriangle & operator=(const SphericalTriangle &other)=default
static Self zero
Static const for zero PointVector.
const RealVector & C() const
Aim: Defines the concept describing a digital space, ie a cartesian product of integer lines.
RealVector myB
The point B of the triangle ABC, of unit length.
DGtal::uint32_t Dimension
void interiorAngles(Scalar &alpha, Scalar &beta, Scalar &gamma) const
Scalar algebraicArea() const
UnsignedComponent norm1() const
void setC(const RealVector &vc, bool normalize=true)
TEuclideanRing Component
Type for Vector elements.
auto crossProduct(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::crossProduct(*this, v))
Cross product with a PointVector.
Space::RealVector RealVector
const RealVector & A() const
bool isDegenerate() const
DGtal is the top-level namespace which contains all DGtal functions and types.
const RealVector & B() const
static const Dimension dimension
static constants to store the dimension.
Self polarTriangle() const
RealVector myA
The point A of the triangle ABC, of unit length.
Space::RealPoint RealPoint
SphericalTriangle< Space > Self
BOOST_STATIC_ASSERT((Space::dimension==3))
double norm(const NormType type=L_2) const
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.
auto dot(const PointVector< dim, OtherComponent, OtherStorage > &v) const -> decltype(DGtal::dotProduct(*this, v))
Dot product with a PointVector.
BOOST_CONCEPT_ASSERT((concepts::CSpace< TSpace >))
Aim: Implements basic operations that will be used in Point and Vector classes.
void setB(const RealVector &vb, bool normalize=true)
RealVector myC
The point C of the triangle ABC, of unit length.
SphericalTriangle(const RealVector &va, const RealVector &vb, const RealVector &vc, bool normalize=true)
Default constructor. The object is invalid.
RealVector::Component Scalar