DGtal  1.3.beta
Lemniscate2D.h
1 
17 #pragma once
18 
31 #if defined(Lemniscate2D_RECURSES)
32 #error Recursive header files inclusion detected in Lemniscate2D.h
33 #else // defined(Lemniscate2D_RECURSES)
34 
35 #define Lemniscate2D_RECURSES
36 
37 #if !defined Lemniscate2D_h
38 
39 #define Lemniscate2D_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <DGtal/base/Common.h>
45 #include <DGtal/shapes/parametric/StarShaped2D.h>
46 #include <cmath>
48 
49 namespace DGtal
50 {
51 
53  // template class Lemniscate2D
60  template <typename TSpace>
61  class Lemniscate2D : public DGtal::StarShaped2D<TSpace>
62  {
63  // ----------------------- Standard services ------------------------------
64  public:
65 
66  typedef TSpace Space;
67  typedef typename Space::RealPoint RealPoint;
68  typedef typename Space::RealVector RealVector;
69 
74  Lemniscate2D() = delete;
75 
83  Lemniscate2D( const double x0, const double y0,
84  const double a );
85 
93  Lemniscate2D( const RealPoint& aPoint, const double a );
94 
99  Lemniscate2D( const Lemniscate2D& other );
100 
107  Lemniscate2D& operator=( const Lemniscate2D& other ) = delete;
108 
112  ~Lemniscate2D() = default;
113 
114  // ------------- Implementation of 'StarShaped' services ------------------
115  public:
116 
122  {
123  return RealPoint( myCenter[0] - myA, myCenter[1] - myA * 0.5 );
124  }
125 
131  {
132  return RealPoint( myCenter[0] + myA, myCenter[1] + myA * 0.5 );
133  }
134 
139  {
140  return myCenter;
141  }
142 
147  inline
148  void moveTo( const RealPoint& newCenter )
149  {
150  myCenter = newCenter;
151  }
152 
159  double parameter( const RealPoint & p ) const;
160 
167  RealPoint x( const double t ) const;
168 
175  RealVector xp( const double t ) const;
176 
182  RealVector xpp( const double t ) const;
183 
184 
185  // ------------------------- data -----------------------------------------
186  private:
187 
192 
196  double myA;
197 
198  // ----------------------- Interface --------------------------------------
199  public:
200 
205  void selfDisplay ( std::ostream & out ) const;
206 
207 
212  bool isValid() const;
213 
214  // ------------------------- Hidden services ------------------------------
215  private:
216 
220  template <typename T>
221  inline
222  bool isAlmostEqual( T x, T y ) const
223  {
224  return std::abs(x - y) <= std::numeric_limits<T>::epsilon();
225  }
226 
227  }; // end of class Lemniscate2D
228 
229 
230 
237  template <typename T>
238  std::ostream&
239  operator<< ( std::ostream & out, const Lemniscate2D<T> & object );
240 
241 } // namespace DGtal
242 
243 
245 // Includes inline functions.
246 #include "DGtal/shapes/parametric/Lemniscate2D.ih"
247 
248 // //
250 
251 #endif // !defined Lemniscate2D_h
252 
253 #undef Lemniscate2D_RECURSES
254 #endif // else defined(Lemniscate2D_RECURSES)
DGtal::Lemniscate2D::Space
TSpace Space
Definition: Lemniscate2D.h:66
DGtal::Lemniscate2D::x
RealPoint x(const double t) const
DGtal::Lemniscate2D::~Lemniscate2D
~Lemniscate2D()=default
aPoint
const Point aPoint(3, 4)
DGtal::StarShaped2D
Definition: StarShaped2D.h:74
DGtal::Lemniscate2D::parameter
double parameter(const RealPoint &p) const
DGtal::Lemniscate2D::myCenter
RealPoint myCenter
Definition: Lemniscate2D.h:191
DGtal::Lemniscate2D::operator=
Lemniscate2D & operator=(const Lemniscate2D &other)=delete
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::Lemniscate2D::Lemniscate2D
Lemniscate2D()=delete
DGtal::Lemniscate2D::getUpperBound
RealPoint getUpperBound() const
Definition: Lemniscate2D.h:130
DGtal::Lemniscate2D::center
RealPoint center() const
Definition: Lemniscate2D.h:138
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::Lemniscate2D::myA
double myA
Definition: Lemniscate2D.h:196
DGtal::Lemniscate2D::RealVector
Space::RealVector RealVector
Definition: Lemniscate2D.h:68
DGtal::Lemniscate2D::getLowerBound
RealPoint getLowerBound() const
Definition: Lemniscate2D.h:121
DGtal::Lemniscate2D::moveTo
void moveTo(const RealPoint &newCenter)
Definition: Lemniscate2D.h:148
DGtal::Lemniscate2D::xpp
RealVector xpp(const double t) const
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::Lemniscate2D::xp
RealVector xp(const double t) const
DGtal::Lemniscate2D
Aim: Model of the concept StarShaped represents a lemniscate.
Definition: Lemniscate2D.h:61
DGtal::Lemniscate2D::isValid
bool isValid() const
DGtal::Lemniscate2D::isAlmostEqual
bool isAlmostEqual(T x, T y) const
Definition: Lemniscate2D.h:222
DGtal::Lemniscate2D::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::Lemniscate2D::RealPoint
Space::RealPoint RealPoint
Definition: Lemniscate2D.h:67