DGtal 1.3.0
Loading...
Searching...
No Matches
Astroid2D.h
1
17#pragma once
18
31#if defined(Astroid2D_RECURSES)
32#error Recursive header files inclusion detected in Astroid2D.h
33#else // defined(Astroid2D_RECURSES)
35#define Astroid2D_RECURSES
36
37#if !defined Astroid2D_h
39#define Astroid2D_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 Astroid2D
60 template <typename TSpace>
61 class Astroid2D : public 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 Astroid2D() = delete;
75
84 Astroid2D( const double x0, const double y0,
85 const double a, const double b );
86
94 Astroid2D( const RealPoint& aPoint, const double a, const double b );
95
100 Astroid2D( const Astroid2D& other );
101
108 Astroid2D& operator= ( const Astroid2D& other ) = delete;
109
113 ~Astroid2D() = default;
114
115 // ------------- Implementation of 'StarShaped' services -------------------
116 public:
117
123 {
124 return RealPoint( myCenter[0] - myA, myCenter[1] - myB );
125 }
126
132 {
133 return RealPoint( myCenter[0] + myA, myCenter[1] + myB );
134 }
135
140 {
141 return myCenter;
142 }
143
148 inline
149 void moveTo( const RealPoint& newCenter )
150 {
151 myCenter = newCenter;
152 }
153
160 double parameter( const RealPoint & p ) const;
161
162
169 RealPoint x( const double t ) const;
170
177 RealVector xp( const double t ) const;
178
184 RealVector xpp( const double t ) const;
185
186
187 // ------------------------- data -----------------------------------------
188 private:
189
194
198 double myA;
199
203 double myB;
204
205 // ----------------------- Interface --------------------------------------
206 public:
207
212 void selfDisplay ( std::ostream & out ) const;
213
214
219 bool isValid() const;
220
221 // ------------------------- Hidden services ------------------------------
222 private:
223
227 template <typename T>
228 inline
229 bool isAlmostEqual( T x, T y ) const
230 {
231 return std::abs(x - y) <= std::numeric_limits<T>::epsilon();
232 }
233
234 }; // end of class Astroid2D
235
236
237
244 template <typename T>
245 std::ostream&
246 operator<< ( std::ostream & out, const Astroid2D<T> & object );
247
248} // namespace DGtal
249
250
252// Includes inline functions.
253#include "DGtal/shapes/parametric/Astroid2D.ih"
254
255// //
257
258#endif // !defined Astroid2D_h
259
260#undef Astroid2D_RECURSES
261#endif // else defined(Astroid2D_RECURSES)
Aim: Model of the concept StarShaped represents an astroid.
Definition: Astroid2D.h:62
Astroid2D & operator=(const Astroid2D &other)=delete
bool isValid() const
RealPoint getLowerBound() const
Definition: Astroid2D.h:122
void moveTo(const RealPoint &newCenter)
Definition: Astroid2D.h:149
RealVector xpp(const double t) const
RealPoint x(const double t) const
RealVector xp(const double t) const
Astroid2D()=delete
Space::RealVector RealVector
Definition: Astroid2D.h:68
RealPoint center() const
Definition: Astroid2D.h:139
RealPoint myCenter
Definition: Astroid2D.h:193
RealPoint getUpperBound() const
Definition: Astroid2D.h:131
Space::RealPoint RealPoint
Definition: Astroid2D.h:67
Astroid2D(const RealPoint &aPoint, const double a, const double b)
Astroid2D(const double x0, const double y0, const double a, const double b)
Astroid2D(const Astroid2D &other)
void selfDisplay(std::ostream &out) const
bool isAlmostEqual(T x, T y) const
Definition: Astroid2D.h:229
~Astroid2D()=default
double parameter(const RealPoint &p) const
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593
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)