9#include <kernel/analytic/static_wrapper.hpp>
10#include <kernel/analytic/wrappers.hpp>
11#include <kernel/util/math.hpp>
12#include <kernel/geometry/cgal.hpp>
42 template<
int dim_,
typename DataType_>
47 static constexpr int domain_dim = dim_;
49 static constexpr bool can_value =
true;
50 static constexpr bool can_grad =
true;
51 static constexpr bool can_hess =
true;
56 template<
typename EvalTraits_>
62 typedef typename EvalTraits_::DataType
DataType;
85 return (point -
_origin).norm_euclid();
92 if(norm < Math::eps<DataType>())
93 return GradientType::null();
101 if(norm < Math::eps<DataType>())
102 return HessianType::null();
108 for(
int i(0); i < dim_; ++i)
111 for(
int j(0); j < dim_; ++j)
160 template<
int dim_,
typename DataType_>
165 static constexpr int domain_dim = dim_;
168 static constexpr bool can_value =
true;
169 static constexpr bool can_grad =
true;
170 static constexpr bool can_hess =
true;
175 template<
typename EvalTraits_>
208 return _a + _b*(point -
_origin).norm_euclid();
214 if(norm < Math::eps<DataType>())
215 return GradientType::null();
217 return (_b / norm) * (point -
_origin);
223 if(norm <= Math::eps<DataType>())
224 return HessianType::null();
231 for(
int i(0); i < dim_; ++i)
233 hess[i][i] = _b*norm;
234 for(
int j(0); j < dim_; ++j)
284 template<
int component_,
int dim_,
typename DataType_>
289 static constexpr int domain_dim = dim_;
292 static constexpr bool can_value =
true;
293 static constexpr bool can_grad =
true;
294 static constexpr bool can_hess =
true;
299 template<
typename EvalTraits_>
337 if(norm < Math::eps<DataType>())
338 return GradientType::null();
348 return HessianType::null();
389 template<
int dim_,
typename DataType_>
394 static constexpr int domain_dim = dim_;
396 static constexpr bool can_value =
true;
397 static constexpr bool can_grad =
true;
398 static constexpr bool can_hess =
true;
403 template<
typename EvalTraits_>
439 if(norm_sqr < Math::eps<DataType>())
440 return GradientType::null();
448 if(norm_sqr < Math::eps<DataType>())
449 return HessianType::null();
453 for(
int i(0); i < dim_; ++i)
455 for(
int j(0); j < dim_; ++j)
459 for(
int k(0); k < dim_; ++k)
511 template<
typename DT_>
516 typedef DT_ DataType;
520 static constexpr int domain_dim = 3;
522 static constexpr bool can_value =
true;
524 static constexpr bool can_grad =
false;
526 static constexpr bool can_hess =
false;
545 _cgal_wrapper(filestream_, filemode_)
550 template<
typename EvalTraits_>
556 typedef typename EvalTraits_::DataType DataType;
558 typedef typename EvalTraits_::PointType PointType;
560 typedef typename EvalTraits_::ValueType ValueType;
562 typedef typename EvalTraits_::GradientType GradientType;
564 typedef typename EvalTraits_::HessianType HessianType;
568 typedef typename CGALDistanceFunction::DataType IDT_;
572 explicit Evaluator(
const CGALDistanceFunction& function) :
573 _cgal_wrapper(&function._cgal_wrapper)
577 ValueType value(
const PointType& point)
579 return ((_cgal_wrapper->
point_inside(IDT_(point[0]), IDT_(point[1]), IDT_(point[2])) ? ValueType(1) : ValueType(-1)) *
580 ValueType(Math::sqrt(_cgal_wrapper->
squared_distance(IDT_(point[0]), IDT_(point[1]), IDT_(point[2])))));
EvalTraits_::HessianType HessianType
hessian type
Evaluator(const DistanceFunction &function)
Constructor.
const PointType _origin
our origin
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::ValueType ValueType
value type
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::DataType DataType
coefficient data type
Analytic distance function.
void set_point(const PointType &origin)
Sets point to x0
PointType _origin
Point to calculate the distance from.
DistanceFunction()
default constructor
DistanceFunction(const PointType &origin)
Constructor.
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::ValueType ValueType
value type
EvalTraits_::HessianType HessianType
hessian type
const PointType _origin
our origin
Evaluator(const DistanceFunctionSD &function)
Constructor.
const DataType _a
displacement and scaling factor
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::PointType PointType
evaluation point type
Scaled and displaced analytic distance function.
DataType_ _b
Scaling factor.
void set_point(const PointType &origin)
Sets point to x0
DistanceFunctionSD(const PointType &origin, const DataType_ a_, const DataType_ b_)
Constructor.
PointType _origin
The point to which the distance to is calculated.
DataType_ _a
Displacement of the function.
EvalTraits_::ValueType ValueType
value type
EvalTraits_::HessianType HessianType
hessian type
EvalTraits_::PointType PointType
evaluation point type
const PointType _origin
our origin
EvalTraits_::GradientType GradientType
gradient type
EvalTraits_::DataType DataType
coefficient data type
Evaluator(const InverseDistanceFunction &function)
Constructor.
Analytic inverse distance function.
void set_point(const PointType &origin)
Sets point to x0
InverseDistanceFunction()
default constructor
PointType _origin
Point to calculate the distance from.
InverseDistanceFunction(const PointType &origin)
Constructor.
const PointType _origin
our origin
EvalTraits_::GradientType GradientType
gradient type
const DataType_ _b
our scaling
Evaluator(const PlaneDistanceFunctionSD &function)
Constructor.
EvalTraits_::ValueType ValueType
value type
EvalTraits_::DataType DataType
coefficient data type
EvalTraits_::PointType PointType
evaluation point type
EvalTraits_::HessianType HessianType
hessian type
Scaled and displaced analytic distance from i-th coordinate axis/plane function.
PointType _origin
The point to which the distance to is calculated.
void set_point(const PointType &origin)
Sets point to x0
PlaneDistanceFunctionSD(const PointType &origin, const DataType_ b_)
Constructor.
DataType_ _b
Scaling factor.
Analytic Function Evaluator base-class template.
Analytic Function interface.
Wrapper for the CGAL Library.
bool point_inside(DataType x, DataType y, DataType z) const
Check whether a point is inside the Polyhedron defined at objects' construction.
DataType squared_distance(DataType x, DataType y, DataType z) const
Returns the minimun squared distance between the query point and all input primitives defined at obje...
Tiny Vector class template.
CUDA_HOST_DEVICE void format(DataType alpha=DataType(0))
Formats the vector.
T_ abs(T_ x)
Returns the absolute value.
T_ pow(T_ x, T_ y)
Returns x raised to the power of y.
T_ sqr(T_ x)
Returns the square of a value.
T_ signum(T_ x)
Returns the sign of a value.
@ value
specifies whether the space should supply basis function values
@ hess
specifies whether the space should supply basis function hessians
@ grad
specifies whether the space should supply basis function gradients
Scalar Function Image tag class.