DGtal 1.4.2
Loading...
Searching...
No Matches
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)
35#define Lemniscate2D_RECURSES
36
37#if !defined Lemniscate2D_h
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
49namespace 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)
Aim: Model of the concept StarShaped represents a lemniscate.
void moveTo(const RealPoint &newCenter)
bool isValid() const
Lemniscate2D(const RealPoint &aPoint, const double a)
bool isAlmostEqual(T x, T y) const
Lemniscate2D & operator=(const Lemniscate2D &other)=delete
Lemniscate2D(const Lemniscate2D &other)
RealVector xp(const double t) const
RealPoint getUpperBound() const
void selfDisplay(std::ostream &out) const
RealPoint getLowerBound() const
RealPoint x(const double t) const
double parameter(const RealPoint &p) const
RealVector xpp(const double t) const
Space::RealVector RealVector
Space::RealPoint RealPoint
Lemniscate2D(const double x0, const double y0, const double a)
RealPoint center() const
~Lemniscate2D()=default
Aim: Implements basic operations that will be used in Point and Vector classes.
PointVector< dim, double > RealPoint
Definition SpaceND.h:117
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
const Point aPoint(3, 4)