DGtal 1.4.0
Loading...
Searching...
No Matches
ImplicitRoundedHyperCube.h
1
17#pragma once
18
31#if defined(ImplicitRoundedHyperCube_RECURSES)
32#error Recursive header files inclusion detected in ImplicitRoundedHyperCube.h
33#else // defined(ImplicitRoundedHyperCube_RECURSES)
35#define ImplicitRoundedHyperCube_RECURSES
36
37#if !defined ImplicitRoundedHyperCube_h
39#define ImplicitRoundedHyperCube_h
40
42// Inclusions
43#include <iostream>
44#include "DGtal/base/Common.h"
46
47namespace DGtal
48{
49
52
61 template <typename TSpace>
63 {
64
65 public:
67 typedef TSpace Space;
68 typedef typename Space::RealPoint RealPoint;
69 typedef double Value;
70
80 const double &aHalfWidth,
81 const double aPower):
82 myCenter(aCenter),
83 myHalfWidth(aHalfWidth),
84 myPower(aPower)
85 {};
86
92
93
94 // ----------------------- Interface --------------------------------------
95 public:
96
105 inline
106 double operator()(const RealPoint &aPoint) const
107 {
108 RealPoint dec = (aPoint - myCenter);
109 double partialpower=0;
110 for(Dimension i = 0; i < RealPoint::dimension; ++i)
111 partialpower += std::pow(std::abs((double)dec[i]), myPower);
112
113 return std::pow(myHalfWidth, myPower) - partialpower;
114 }
115
122 inline
123 bool isInside(const RealPoint &aPoint) const
124 {
125 return this->operator()(aPoint) >0.0;
126 }
127
135 inline
137 {
138 if (this->operator()(aPoint) > 0.0)
139 return INSIDE;
140 else
141 if (this->operator()(aPoint) < 0.0)
142 return OUTSIDE;
143 else
144 return ON;
145 }
146
147
154 inline
156 {
158 }
159
166 inline
168 {
170 }
171
176 {
177 return myCenter;
178 }
179
184 inline
185 void moveTo( const RealPoint& newCenter )
186 {
187 myCenter = newCenter;
188 }
189
190 // ----------------------- Interface --------------------------------------
191 public:
192
197 void selfDisplay ( std::ostream & out ) const;
198
203 bool isValid() const;
204
205 // ------------------------- Protected Datas ------------------------------
206 private:
207 // ------------------------- Private Datas --------------------------------
208 private:
209
212
215
217 double myPower;
218
219 // ------------------------- Hidden services ------------------------------
220 protected:
221
227
228 private:
229
237
238
239 }; // end of class ImplicitRoundedHyperCube
240
241
248 template <typename T>
249 std::ostream&
250 operator<< ( std::ostream & out, const ImplicitRoundedHyperCube<T> & object );
251
252} // namespace DGtal
253
254
256// Includes inline functions.
257#include "DGtal/shapes/implicit/ImplicitRoundedHyperCube.ih"
258
259// //
261
262#endif // !defined ImplicitRoundedHyperCube_h
263
264#undef ImplicitRoundedHyperCube_RECURSES
265#endif // else defined(ImplicitRoundedHyperCube_RECURSES)
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a rounded hypercu...
void moveTo(const RealPoint &newCenter)
ImplicitRoundedHyperCube(const RealPoint &aCenter, const double &aHalfWidth, const double aPower)
bool isInside(const RealPoint &aPoint) const
double operator()(const RealPoint &aPoint) const
void selfDisplay(std::ostream &out) const
ImplicitRoundedHyperCube & operator=(const ImplicitRoundedHyperCube &other)
ImplicitRoundedHyperCube< TSpace > Self
Orientation orientation(const RealPoint &aPoint) const
Aim: Implements basic operations that will be used in Point and Vector classes.
static Self diagonal(Component val=1)
static const Dimension dimension
Copy of the static dimension of the Point/Vector.
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
DGtal::uint32_t Dimension
Definition Common.h:136
Orientation
Definition Common.h:141
@ INSIDE
Definition Common.h:141
@ OUTSIDE
Definition Common.h:141
@ ON
Definition Common.h:141
const Point aPoint(3, 4)