DGtal  0.9.2
Ball2D.h
1 
17 #pragma once
18 
31 #if defined(Ball2D_RECURSES)
32 #error Recursive header files inclusion detected in Ball2D.h
33 #else // defined(Ball2D_RECURSES)
34 
35 #define Ball2D_RECURSES
36 
37 #if !defined Ball2D_h
38 
39 #define Ball2D_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/shapes/parametric/StarShaped2D.h"
47 
48 namespace DGtal
49 {
50 
52  // template class Ball2D
59  template <typename TSpace>
60  class Ball2D: public StarShaped2D<TSpace>
61  {
62  // ----------------------- Standard services ------------------------------
63  public:
64 
65  typedef TSpace Space;
66  typedef typename Space::Point Point;
67  typedef typename Space::RealPoint RealPoint2D;
68  typedef typename Space::RealVector RealVector2D;
69 
73  ~Ball2D();
74 
81  Ball2D( const double x0, const double y0, const double r );
82 
88  Ball2D(const RealPoint2D &aPoint, const double r);
89 
95  Ball2D(const Point &aPoint, const double r);
96 
97 
98  // ------------- Implementation of 'StarShaped' services ------------------
99  public:
100 
105  RealPoint2D getLowerBound() const
106  {
107  return RealPoint2D(myCenter[0] - myRadius, myCenter[1] - myRadius);
108  }
109 
114  RealPoint2D getUpperBound() const
115  {
116  return RealPoint2D(myCenter[0] + myRadius, myCenter[1] + myRadius);
117  }
118 
122  RealPoint2D center() const
123  {
124  return myCenter;
125  }
126 
133  double parameter( const RealPoint2D & p ) const;
134 
135 
142  RealPoint2D x( const double t ) const;
143 
150  RealVector2D xp( const double t ) const;
151 
157  RealVector2D xpp( const double t ) const;
158 
159 
160  // ------------------------- data ----------------------------
161  private:
162 
166  double myRadius;
167 
171  RealPoint2D myCenter;
172 
173 
174  // ----------------------- Interface --------------------------------------
175  public:
176 
181  void selfDisplay ( std::ostream & out ) const;
182 
187  bool isValid() const;
188 
189 
190  // ------------------------- Hidden services ------------------------------
191  protected:
192 
197  Ball2D();
198 
199  private:
200 
206  // Ball2D ( const Ball2D & other );
207 
214  Ball2D & operator= ( const Ball2D & other );
215 
216  // ------------------------- Internals ------------------------------------
217  private:
218 
219  }; // end of class Ball2D
220 
221 
228  template <typename T>
229  std::ostream&
230  operator<< ( std::ostream & out, const Ball2D<T> & object );
231 
232 } // namespace DGtal
233 
234 
236 // Includes inline functions.
237 #include "DGtal/shapes/parametric/Ball2D.ih"
238 
239 // //
241 
242 #endif // !defined Ball2D_h
243 
244 #undef Ball2D_RECURSES
245 #endif // else defined(Ball2D_RECURSES)
RealPoint2D myCenter
Definition: Ball2D.h:171
RealVector2D xpp(const double t) const
Space::RealPoint RealPoint2D
Definition: Ball2D.h:67
bool isValid() const
PointVector< dim, double > RealPoint
Definition: SpaceND.h:117
double parameter(const RealPoint2D &p) const
RealPoint2D center() const
Definition: Ball2D.h:122
Ball2D & operator=(const Ball2D &other)
Aim: Model of the concept StarShaped represents any circle in the plane.
Definition: Ball2D.h:60
Space::RealVector RealVector2D
Definition: Ball2D.h:68
RealVector2D xp(const double t) const
RealPoint2D getLowerBound() const
Definition: Ball2D.h:105
RealPoint2D x(const double t) const
DGtal is the top-level namespace which contains all DGtal functions and types.
RealPoint2D getUpperBound() const
Definition: Ball2D.h:114
double myRadius
Definition: Ball2D.h:166
TSpace Space
Definition: Ball2D.h:65
Space::Point Point
Definition: Ball2D.h:66
void selfDisplay(std::ostream &out) const