48 #ifndef _SUPER4PCS_ACCELERATORS_INTERSECTION_PRIMITIVES_H_ 49 #define _SUPER4PCS_ACCELERATORS_INTERSECTION_PRIMITIVES_H_ 52 #define SQR(a) ((a)*(a)) 58 namespace Accelerators{
59 namespace PairExtraction{
61 template <
class Po
int,
int _dim,
typename Scalar>
69 struct CustomFloorExpr{
70 inline CustomFloorExpr(Scalar e) : m_e(e) {}
71 inline const Scalar operator()(
const Scalar &x)
const 73 return std::round(x/m_e) * m_e;
80 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
84 : _center(center), _radius(radius) { }
87 : _center(other._center), _radius(other._radius) { }
92 CustomFloorExpr expr (eps);
98 inline bool operator<(const HyperSphere<Point, _dim, Scalar>& other)
const{
99 if (_radius != other._radius)
100 return _radius < other._radius;
101 for(
int i = 0; i <
Dim; i++ ) {
102 if (_center[i] == other._center[i])
continue;
103 if (_center[i] < other._center[i])
return true;
110 inline operator Point()
const {
return _center; }
117 inline bool intersect(
const Point& nodeCenter, Scalar halfEdgeLength)
const 119 const Point min = nodeCenter.array() - halfEdgeLength;
120 const Point max = nodeCenter.array() + halfEdgeLength;
121 const Point sqmin = (_center.array() - min.array()).square();
122 const Point sqmax = (_center.array() - max.array()).square();
130 Scalar dmin = (_center.array() < min.array())
133 (_center.array() > max.array()).select(sqmax,Point::Zero())
136 return ( dmin < _radius*_radius &&
137 _radius*_radius < sqmin.cwiseMax(sqmax).sum() );
149 inline bool intersectFast(
const Point& nodeCenter, Scalar halfEdgeLength)
const 151 return SQR((nodeCenter-_center).norm()-halfEdgeLength) <= _radius;
156 return SQR((pos - _center).norm()-_radius) < SQR(epsilon);
162 return SQR((pos - center).norm()-radius) < SQR(epsilon);
165 inline const Point&
center()
const {
return _center;}
166 inline const Scalar &
radius()
const {
return _radius;}
167 inline Scalar&
radius() {
return _radius; }
bool intersectFast(const Point &nodeCenter, Scalar halfEdgeLength) const
intersectFast Fast but inacurate intersection test
Definition: intersectionPrimitive.h:149
Definition: intersectionPrimitive.h:62
bool intersect(const Point &nodeCenter, Scalar halfEdgeLength) const
Definition: intersectionPrimitive.h:117
bool intersectPoint(const Point &pos, Scalar epsilon) const
Definition: intersectionPrimitive.h:154
static bool intersectPoint(const Point &pos, Scalar epsilon, const Point ¢er, const Scalar &radius)
Definition: intersectionPrimitive.h:159
const Scalar & radius() const
Definition: intersectionPrimitive.h:166
HyperSphere(const HyperSphere< Point, _dim, Scalar > &other)
Definition: intersectionPrimitive.h:86
HyperSphere< Point, _dim, Scalar > quantified(Scalar eps) const
Construct a copy of the instance with a quantified radius and pos.
Definition: intersectionPrimitive.h:90
HyperSphere(const Point ¢er, Scalar radius)
Definition: intersectionPrimitive.h:83
Scalar & radius()
Definition: intersectionPrimitive.h:167
Definition: intersectionPrimitive.h:81
const Point & center() const
Definition: intersectionPrimitive.h:165