DGtal  0.9.2
Ellipse2D.h
1
17 #pragma once
18
33 #if defined(Ellipse2D_RECURSES)
34 #error Recursive header files inclusion detected in Ellipse2D.h
35 #else // defined(Ellipse2D_RECURSES)
36
37 #define Ellipse2D_RECURSES
38
39 #if !defined Ellipse2D_h
40
41 #define Ellipse2D_h
42
44 // Inclusions
45 #include <iostream>
46 #include "DGtal/base/Common.h"
47 #include "DGtal/shapes/parametric/StarShaped2D.h"
48 #include <cmath>
50
51 namespace DGtal
52 {
53
55  // template class Ellipse2D
63  template <typename TSpace>
64  class Ellipse2D: public StarShaped2D<TSpace>
65  {
66  // ----------------------- Standard services ------------------------------
67  public:
68
69  typedef TSpace Space;
70  typedef typename Space::Point Point;
71  typedef typename Space::RealPoint RealPoint2D;
72  typedef typename Space::RealVector RealVector2D;
73
77  ~Ellipse2D();
78
87  Ellipse2D( const double x0, const double y0,
88  const double a0, const double a1, const double theta);
89
97  Ellipse2D(const RealPoint2D &aPoint,
98  const double a0, const double a1, const double theta);
99
107  Ellipse2D(const Point &aPoint,
108  const double a0, const double a1, const double theta);
109
110
111  // ------------- Implementation of 'StarShaped' services ------------------
112  public:
113
118  RealPoint2D getLowerBound() const
119  {
120  return RealPoint2D(myCenter[0] - myAxis1, myCenter[1] - myAxis1);
121  }
122
127  RealPoint2D getUpperBound() const
128  {
129  return RealPoint2D(myCenter[0] + myAxis1, myCenter[1] + myAxis1);
130  }
131
135  RealPoint2D center() const
136  {
137  return myCenter;
138  }
139
146  double parameter( const RealPoint2D & p ) const;
147
148
155  RealPoint2D x( const double t ) const;
156
163  RealVector2D xp( const double t ) const;
164
170  RealVector2D xpp( const double t ) const;
171
172
173  // ------------------------- data ----------------------------
174  private:
175
179  RealPoint2D myCenter;
180
184  double myAxis1;
185
186
190  double myAxis2;
191
195  double myTheta;
196
197  // ----------------------- Interface --------------------------------------
198  public:
199
204  void selfDisplay ( std::ostream & out ) const;
205
210  bool isValid() const;
211
212
213  // ------------------------- Hidden services ------------------------------
214  protected:
215
220  Ellipse2D();
221
222  private:
223
229  // Ellipse2D ( const Ellipse2D & other );
230
237  Ellipse2D & operator= ( const Ellipse2D & other );
238
239  // ------------------------- Internals ------------------------------------
240  private:
241
242  }; // end of class Ellipse2D
243
244
251  template <typename T>
252  std::ostream&
253  operator<< ( std::ostream & out, const Ellipse2D<T> & object );
254
255 } // namespace DGtal
256
257
259 // Includes inline functions.
260 #include "DGtal/shapes/parametric/Ellipse2D.ih"
261
262 // //
264
265 #endif // !defined Ellipse2D_h
266
267 #undef Ellipse2D_RECURSES
268 #endif // else defined(Ellipse2D_RECURSES)
Space::RealVector RealVector2D
Definition: Ellipse2D.h:72
RealPoint2D center() const
Definition: Ellipse2D.h:135
Ellipse2D & operator=(const Ellipse2D &other)
bool isValid() const
Aim: Model of the concept StarShaped represents any ellipse in the plane.
Definition: Ellipse2D.h:64
PointVector< dim, double > RealPoint
Definition: SpaceND.h:117
Space::RealPoint RealPoint2D
Definition: Ellipse2D.h:71
RealPoint2D getLowerBound() const
Definition: Ellipse2D.h:118
DGtal is the top-level namespace which contains all DGtal functions and types.
RealPoint2D getUpperBound() const
Definition: Ellipse2D.h:127
RealVector2D xp(const double t) const
RealVector2D xpp(const double t) const
Space::Point Point
Definition: Ellipse2D.h:70
RealPoint2D x(const double t) const
double parameter(const RealPoint2D &p) const
void selfDisplay(std::ostream &out) const
RealPoint2D myCenter
Definition: Ellipse2D.h:179