48 #ifndef _OPENGR_ACCELERATORS_INTERSECTION_PRIMITIVES_H_ 49 #define _OPENGR_ACCELERATORS_INTERSECTION_PRIMITIVES_H_ 52 #define SQR(a) ((a)*(a)) 59 template <
class Point,
int _dim,
typename Scalar>
67 struct CustomFloorExpr{
68 inline CustomFloorExpr(Scalar e) : m_e(e) {}
69 inline const Scalar operator()(
const Scalar &x)
const 71 return std::round(x/m_e) * m_e;
78 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
82 : _center(center), _radius(radius) { }
85 : _center(other._center), _radius(other._radius) { }
90 CustomFloorExpr expr (eps);
91 return HyperSphere<Point, _dim, Scalar>(_center.unaryExpr(expr),
97 if (_radius != other._radius)
98 return _radius < other._radius;
99 for(
int i = 0; i <
Dim; i++ ) {
100 if (_center[i] == other._center[i])
continue;
101 if (_center[i] < other._center[i])
return true;
115 inline bool intersect(
const Point& nodeCenter, Scalar halfEdgeLength)
const 117 const Point min = nodeCenter.array() - halfEdgeLength;
118 const Point max = nodeCenter.array() + halfEdgeLength;
119 const Point sqmin = (_center.array() - min.array()).square();
120 const Point sqmax = (_center.array() - max.array()).square();
128 Scalar dmin = (_center.array() < min.array())
131 (_center.array() > max.array()).select(sqmax,Point::Zero())
134 return ( dmin < _radius*_radius &&
135 _radius*_radius < sqmin.cwiseMax(sqmax).sum() );
147 inline bool intersectFast(
const Point& nodeCenter, Scalar halfEdgeLength)
const 149 return SQR((nodeCenter-_center).norm()-halfEdgeLength) <= _radius;
154 return SQR((pos - _center).norm()-_radius) <
SQR(epsilon);
158 const Point& center,
const Scalar &radius )
160 return SQR((pos - center).norm()-radius) <
SQR(epsilon);
163 inline const Point&
center()
const {
return _center;}
164 inline const Scalar &
radius()
const {
return _radius;}
165 inline Scalar&
radius() {
return _radius; }
bool intersectPoint(const Point &pos, Scalar epsilon) const
Definition: intersectionPrimitive.h:152
const Scalar & radius() const
Definition: intersectionPrimitive.h:164
#define SQR(a)
Definition: intersectionPrimitive.h:52
Definition: intersectionPrimitive.h:60
bool intersect(const Point &nodeCenter, Scalar halfEdgeLength) const
Definition: intersectionPrimitive.h:115
CongruentSetExplorationBase< Traits, PointType, TransformVisitor, PairFilteringFunctor, OptExts... >::Scalar ComputeTransformation(const InputRange1 &P, const InputRange2 &Q, Eigen::Ref< typename CongruentSetExplorationBase< Traits, PointType, TransformVisitor, PairFilteringFunctor, OptExts... >::MatrixType > transformation, const Sampler< PointType > &sampler, TransformVisitor &v)
Definition: congruentSetExplorationBase.hpp:61
HyperSphere(const HyperSphere< Point, _dim, Scalar > &other)
Definition: intersectionPrimitive.h:84
operator Point() const
Implicit conversion operator to Eigen vectors.
Definition: intersectionPrimitive.h:108
HyperSphere(const Point ¢er, Scalar radius)
Definition: intersectionPrimitive.h:81
bool operator<(const HyperSphere< Point, _dim, Scalar > &other) const
Comparison operator comparing first the radius then the position.
Definition: intersectionPrimitive.h:96
Scalar & radius()
Definition: intersectionPrimitive.h:165
HyperSphere< Point, _dim, Scalar > quantified(Scalar eps) const
Construct a copy of the instance with a quantified radius and pos.
Definition: intersectionPrimitive.h:88
const Point & center() const
Definition: intersectionPrimitive.h:163
static bool intersectPoint(const Point &pos, Scalar epsilon, const Point ¢er, const Scalar &radius)
Definition: intersectionPrimitive.h:157
bool intersectFast(const Point &nodeCenter, Scalar halfEdgeLength) const
intersectFast Fast but inacurate intersection test
Definition: intersectionPrimitive.h:147
Definition: intersectionPrimitive.h:79