DGtal  1.1.0
ParametricShapeArcLengthFunctor.h
1 
17 #pragma once
18 
34 #if defined(ParametricShapeArcLengthFunctor_RECURSES)
35 #error Recursive header files inclusion detected in ParametricShapeArcLengthFunctor.h
36 #else // defined(ParametricShapeArcLengthFunctor_RECURSES)
37 
38 #define ParametricShapeArcLengthFunctor_RECURSES
39 
40 #if !defined ParametricShapeArcLengthFunctor_h
41 
42 #define ParametricShapeArcLengthFunctor_h
43 
45 // Inclusions
46 #include <iostream>
47 #include "DGtal/base/Common.h"
49 
50 namespace DGtal
51 {
52 
54  // template class ParametricShapeArcLengthFunctor
63  template <typename TParametricShape>
65  {
66 
67  // ----------------------- Standard services ------------------------------
68  public:
69 
71  typedef TParametricShape ParametricShape;
72 
75 
77  typedef double Quantity;
78 
83 
84 
90 
91 
96 
97 
98  // ----------------------- Interface --------------------------------------
99  public:
107 
115  Quantity operator()(const RealPoint &aFirstPoint,const RealPoint &aSecondPoint) const
116  {
117  //determining nbSamples from the bounding box size of the shape
118  RealPoint v = myShape.getUpperBound() - myShape.getLowerBound();
119  double n = v.norm(RealPoint::L_infty);
120  unsigned int nbSamples = (unsigned int) ceil( n*100 );
121 
122  //computes the angles
123  double t = myShape.parameter( aFirstPoint );
124  double t2 = myShape.parameter( aSecondPoint );
125  return myShape.arclength( t, t2, nbSamples );
126 
127  }
128 
135  {
136  //determining nbSamples from the bounding box size of the shape
137  RealPoint v = myShape.getUpperBound() - myShape.getLowerBound();
138  double n = v.norm(RealPoint::L_infty);
139  unsigned int nbSamples = (unsigned int) ceil( n*100 );
140 
141  return myShape.arclength( 0,2*M_PI, nbSamples );
142  }
143 
144  // ------------------------- Private Datas --------------------------------
145  private:
146 
149 
150  // ------------------------- Internals ------------------------------------
151  private:
152 
153  }; // end of class ParametricShapeArcLengthFunctor
154 
155 } // namespace DGtal
156 
157  //
159 
160 #endif // !defined ParametricShapeArcLengthFunctor_h
161 
162 #undef ParametricShapeArcLengthFunctor_RECURSES
163 #endif // else defined(ParametricShapeArcLengthFunctor_RECURSES)
DGtal::ParametricShapeArcLengthFunctor::myShape
const ParametricShape & myShape
Reference of the implicit shape.
Definition: ParametricShapeArcLengthFunctor.h:148
DGtal::PointVector::L_infty
@ L_infty
Definition: PointVector.h:1488
DGtal::ParametricShapeArcLengthFunctor::RealPoint
TParametricShape::RealPoint RealPoint
Type of const iterator on points.
Definition: ParametricShapeArcLengthFunctor.h:74
DGtal::ParametricShapeArcLengthFunctor::Quantity
double Quantity
Type of the functor output.
Definition: ParametricShapeArcLengthFunctor.h:77
DGtal::ParametricShapeArcLengthFunctor::ParametricShapeArcLengthFunctor
ParametricShapeArcLengthFunctor()=delete
DGtal::ParametricShapeArcLengthFunctor::~ParametricShapeArcLengthFunctor
~ParametricShapeArcLengthFunctor()=default
DGtal::ParametricShapeArcLengthFunctor::operator()
Quantity operator()() const
Definition: ParametricShapeArcLengthFunctor.h:134
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition: ClosedIntegerHalfPlane.h:49
DGtal::ParametricShapeArcLengthFunctor::ParametricShapeArcLengthFunctor
ParametricShapeArcLengthFunctor(const ParametricShape &aShape)
Definition: ParametricShapeArcLengthFunctor.h:89
DGtal::ParametricShapeArcLengthFunctor::operator=
ParametricShapeArcLengthFunctor & operator=(const ParametricShapeArcLengthFunctor &other)=delete
DGtal::ParametricShapeArcLengthFunctor
Aim: implements a functor that estimates the arc length of a paramtric curve.
Definition: ParametricShapeArcLengthFunctor.h:65
DGtal::ParametricShapeArcLengthFunctor::operator()
Quantity operator()(const RealPoint &aFirstPoint, const RealPoint &aSecondPoint) const
Definition: ParametricShapeArcLengthFunctor.h:115
DGtal::ParametricShapeArcLengthFunctor::ParametricShape
TParametricShape ParametricShape
Type of parametric shape.
Definition: ParametricShapeArcLengthFunctor.h:71
RealPoint
Z2i::RealPoint RealPoint
Definition: testAstroid2D.cpp:46