DGtal  1.3.beta
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 final: public StarShaped2D<TSpace>
65  {
66  // ----------------------- Standard services ------------------------------
67  public:
68 
69  typedef TSpace Space;
70  typedef typename Space::RealPoint RealPoint;
71  typedef typename Space::RealVector RealVector;
72 
77  Ellipse2D() = delete;
78 
87  Ellipse2D( const double x0, const double y0,
88  const double a0, const double a1, const double theta );
89 
97  Ellipse2D( const RealPoint& aPoint,
98  const double a0, const double a1, const double theta );
99 
104  Ellipse2D( const Ellipse2D& other );
105 
112  Ellipse2D& operator=( const Ellipse2D& other ) = delete;
113 
117  ~Ellipse2D() = default;
118 
119  // ------------- Implementation of 'StarShaped' services ------------------
120  public:
121 
127  {
128  return myCenter - myAxis1;
129  }
130 
136  {
137  return myCenter + myAxis1;
138  }
139 
144  {
145  return myCenter;
146  }
147 
152  inline
153  void moveTo( const RealPoint& newCenter )
154  {
155  myCenter = newCenter;
156  }
157 
164  double parameter( const RealPoint & p ) const;
165 
166 
173  RealPoint x( const double t ) const;
174 
181  RealVector xp( const double t ) const;
182 
188  RealVector xpp( const double t ) const;
189 
190 
191  // ------------------------- data ----------------------------
192  private:
193 
198 
202  double myAxis1;
203 
204 
208  double myAxis2;
209 
213  double myTheta;
214 
215  // ----------------------- Interface --------------------------------------
216  public:
217 
222  void selfDisplay ( std::ostream & out ) const;
223 
228  bool isValid() const;
229 
230  // ------------------------- Hidden services ------------------------------
231  private:
232 
236  template <typename T>
237  inline
238  bool isAlmostEqual( T x, T y ) const
239  {
240  return std::abs(x - y) <= std::numeric_limits<T>::epsilon();
241  }
242 
243  }; // end of class Ellipse2D
244 
245 
252  template <typename T>
253  std::ostream&
254  operator<< ( std::ostream & out, const Ellipse2D<T> & object );
255 
256 } // namespace DGtal
257 
258 
260 // Includes inline functions.
261 #include "DGtal/shapes/parametric/Ellipse2D.ih"
262 
263 // //
265 
266 #endif // !defined Ellipse2D_h
267 
268 #undef Ellipse2D_RECURSES
269 #endif // else defined(Ellipse2D_RECURSES)
DGtal::Ellipse2D::xpp
RealVector xpp(const double t) const
DGtal::Ellipse2D::myTheta
double myTheta
Definition: Ellipse2D.h:213
DGtal::Ellipse2D::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::Ellipse2D::xp
RealVector xp(const double t) const
DGtal::Ellipse2D::x
RealPoint x(const double t) const
DGtal::Ellipse2D::getLowerBound
RealPoint getLowerBound() const
Definition: Ellipse2D.h:126
aPoint
const Point aPoint(3, 4)
DGtal::Ellipse2D::isAlmostEqual
bool isAlmostEqual(T x, T y) const
Definition: Ellipse2D.h:238
DGtal::Ellipse2D::myCenter
RealPoint myCenter
Definition: Ellipse2D.h:197
DGtal::StarShaped2D
Definition: StarShaped2D.h:74
DGtal::Ellipse2D::parameter
double parameter(const RealPoint &p) const
DGtal::Ellipse2D::operator=
Ellipse2D & operator=(const Ellipse2D &other)=delete
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::Ellipse2D::myAxis1
double myAxis1
Definition: Ellipse2D.h:202
DGtal::Ellipse2D::isValid
bool isValid() const
DGtal::Ellipse2D::myAxis2
double myAxis2
Definition: Ellipse2D.h:208
DGtal::Ellipse2D::Ellipse2D
Ellipse2D()=delete
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::Ellipse2D::RealVector
Space::RealVector RealVector
Definition: Ellipse2D.h:71
DGtal::Ellipse2D::getUpperBound
RealPoint getUpperBound() const
Definition: Ellipse2D.h:135
DGtal::Ellipse2D::RealPoint
Space::RealPoint RealPoint
Definition: Ellipse2D.h:70
DGtal::Ellipse2D
Aim: Model of the concept StarShaped represents any ellipse in the plane.
Definition: Ellipse2D.h:64
DGtal::SpaceND::RealPoint
PointVector< dim, double > RealPoint
Definition: SpaceND.h:117
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
DGtal::Ellipse2D::moveTo
void moveTo(const RealPoint &newCenter)
Definition: Ellipse2D.h:153
DGtal::Ellipse2D::~Ellipse2D
~Ellipse2D()=default
DGtal::Ellipse2D::center
RealPoint center() const
Definition: Ellipse2D.h:143
DGtal::Ellipse2D::Space
TSpace Space
Definition: Ellipse2D.h:69