4#include <boost/fusion/sequence/intrinsic/at_c.hpp>
5#include <boost/fusion/include/at_c.hpp>
6#include <boost/fusion/container/vector.hpp>
7#include <boost/fusion/include/vector.hpp>
8#include <boost/fusion/container/vector/vector_fwd.hpp>
9#include <boost/fusion/include/vector_fwd.hpp>
10#include "boost/multi_array.hpp"
23template<
unsigned int dim ,
typename T>
class Sphere
28 typedef boost::fusion::vector<T[dim],T>
type;
34 static const unsigned int x = 0;
36 static const unsigned int r = 1;
44 __device__ __host__ T
center(
unsigned int i)
46 return boost::fusion::at_c<x>(
data)[i];
61 for (
int i = 0 ; i < dim ; i++)
63 boost::fusion::at_c<x>(
data)[i] = boost::fusion::at_c<x>(sph.
data)[i];
66 boost::fusion::at_c<r>(
data) = boost::fusion::at_c<r>(sph.
data);
78 template<
unsigned int k>
82 for (
int i = 0 ; i < dim ; i++)
84 boost::fusion::at_c<x>(
data)[i] = boost::fusion::at_c<x>(c)[i];
102 for (
int i = 0 ; i < dim ; i++)
104 boost::fusion::at_c<x>(
data)[i] = c.
get(i);
117 return boost::fusion::at_c<r>(
data);
134 for (
int i = 0; i < dim ; i++)
136 dist += (boost::fusion::at_c<x>(
data)[i] - p.
get(i) )*(boost::fusion::at_c<x>(
data)[i] - p.
get(i) );
141 if (dist <= boost::fusion::at_c<r>(
data)*boost::fusion::at_c<r>(
data))
156 template<
typename Distance>
166 for (
int i = 0; i < dim ; i++)
168 dist += d.accum_dist(boost::fusion::at_c<x>(
data)[i],p.
get(i) );
173 if (dist <= boost::fusion::at_c<r>(
data))
187 template<
typename Distance>
bool
197 for (
int i = 0; i < dim ; i++)
199 dist += d.accum_dist(boost::fusion::at_c<x>(
data)[i],pnt[i],i);
204 if (dist <= boost::fusion::at_c<r>(
data))
222 for (
int i = 0; i < dim ; i++)
224 dist += (boost::fusion::at_c<x>(
data)[i] - p.
get(i))*(boost::fusion::at_c<x>(
data)[i] - p.
get(i));
227 return sqrt(dist) -
radius();
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
This class implement the Sphere concept in an N-dimensional space.
__device__ __host__ bool isInside(Point< dim, T > p) const
Check if a point is inside.
__device__ __host__ bool isInside(Point< dim, T > p) const
Check if a point is inside.
Sphere(Point< dim, double > &c, T radius)
Sphere constructor.
__device__ __host__ T distance(Point< dim, T > &p) const
Return the distance from the surface.
static const unsigned int r
property id of the radius of the sphere
type data
Structure that store the data.
static const unsigned int x
property id of the center position of the sphere
Sphere(boost::fusion::vector< T[k]> &c, T radius)
Sphere constructor.
__device__ __host__ Sphere(const Sphere< dim, T > &sph)
Sphere constructor.
boost::fusion::vector< T[dim], T > type
boost fusion that store the point
bool __device__ __host__ isInside(float *pnt) const
Is the point inside the sphere.
__device__ __host__ T center(unsigned int i)
Get the component i of the center.
__device__ __host__ T radius() const
Get the radius of the sphere.