12#include PONCA_MULTIARCH_INCLUDE_STD(cmath)
13#include PONCA_MULTIARCH_INCLUDE_STD(limits)
45template <
class DataPo
int,
class _NFilter,
typename T >
48 PONCA_FITTING_DECLARE_DEFAULT_TYPES
49 static_assert(_NFilter::hasLocalFrame,
"AlgebraicSphere requires local frame");
54 check = Base::PROVIDES_PRIMITIVE_BASE,
75 PONCA_MULTIARCH inline
void init()
80 m_ul = VectorType::Zero();
89 PONCA_MULTIARCH [[nodiscard]]
inline bool isValid()
const{
95 PONCA_MULTIARCH_STD_MATH(pow);
96 const Scalar epsilon = Eigen::NumTraits<Scalar>::dummy_precision();
97 const Scalar squaredEpsilon = epsilon*epsilon;
103 template<
typename Other>
104 PONCA_MULTIARCH [[nodiscard]]
inline bool isApprox(
const Other& other,
const Scalar& epsilon = Eigen::NumTraits<Scalar>::dummy_precision())
const{
105 PONCA_MULTIARCH_STD_MATH(pow);
106 const Scalar squaredEpsilon = epsilon*epsilon;
107 return pow(
m_uc - other.m_uc,
Scalar(2)) < squaredEpsilon &&
108 pow(
m_uq - other.m_uq,
Scalar(2)) < squaredEpsilon &&
109 m_ul.isApprox(other.m_ul);
115 return ! ((*this) == other);
149 VectorType diff = Base::getNeighborFilter().evalPos() - newbasis;
150 Base::getNeighborFilter().changeNeighborhoodFrame(newbasis);
162 PONCA_MULTIARCH_STD_MATH(sqrt);
196 PONCA_MULTIARCH_STD_MATH(numeric_limits);
198 return numeric_limits<Scalar>::infinity();
200 PONCA_MULTIARCH_STD_MATH(sqrt);
211 PONCA_MULTIARCH_STD_MATH(numeric_limits);
213 return VectorType::Constant(numeric_limits<Scalar>::infinity());
216 return Base::getNeighborFilter().convertToGlobalBasis((
Scalar(-0.5)*b)*
m_ul);
227 const VectorType lq = Base::getNeighborFilter().convertToLocalBasis(_q);
250 const VectorType lq = Base::getNeighborFilter().convertToLocalBasis(_q);
262 PONCA_MULTIARCH [[nodiscard]]
inline bool isPlane()
const
264 PONCA_MULTIARCH_STD_MATH(abs);
265 bool bPlanar = Eigen::internal::isApprox(
m_uq,
Scalar(0));
266 bool bReady = Base::isReady();
267 return bReady && bPlanar;
278#include "algebraicSphere.hpp"
Algebraic Sphere primitive.
Scalar potential() const
Value of the scalar field at the evaluation point.
VectorType center() const
return the estimated center of the sphere
bool applyPrattNorm()
Normalize the scalar field by the Pratt norm.
void changeBasis(const VectorType &newbasis)
Express the scalar field relatively to a new basis.
@ check
Requires PrimitiveBase.
@ PROVIDES_ALGEBRAIC_SPHERE
Provides Algebraic Sphere.
const VectorType & primitiveGradient() const
Approximation of the scalar field gradient at the evaluation point.
void init()
Set the scalar field values to 0 and reset the isNormalized() status.
Scalar m_uq
Quadratic parameter of the Algebraic hyper-sphere.
VectorType project(const VectorType &_q) const
Project a point on the algebraic hypersphere.
Scalar m_uc
Constant parameter of the Algebraic hyper-sphere.
typename DataPoint::Scalar Scalar
Alias to scalar type.
Scalar potentialLocal(const VectorType &_lq) const
Value of the scalar field at the location .
VectorType primitiveGradientLocal(const VectorType &_lq) const
Approximation of the scalar field gradient at .
AlgebraicSphere< DataPoint, _NFilter, T > & algebraicSphere()
Explicit conversion to AlgebraicSphere , to access methods potentially hidden by heritage.
bool operator!=(const AlgebraicSphere< DataPoint, NeighborFilter, T > &other) const
Comparison operator, convenience function.
bool m_isNormalized
Is the implicit scalar field normalized using Pratt.
Scalar prattNorm2() const
compute the squared Pratt norm of the implicit scalar field.
bool isApprox(const Other &other, const Scalar &epsilon=Eigen::NumTraits< Scalar >::dummy_precision()) const
Approximate operator.
Scalar prattNorm() const
compute the Pratt norm of the implicit scalar field.
Scalar radius() const
return the estimated radius of the sphere
VectorType m_ul
Linear parameter of the Algebraic hyper-sphere.
typename Base::VectorType VectorType
Alias to vector type.
bool isValid() const
Tell if the sphere as been correctly set. Used to set CONFLICT_ERROR_FOUND during fitting.
bool isPlane() const
Used to know if the fitting result to a plane.
Scalar potential(const VectorType &_q) const
Value of the scalar field at the location .
VectorType primitiveGradient(const VectorType &_q) const
Approximation of the scalar field gradient at .
bool isNormalized() const
State indicating when the sphere has been normalized.
bool operator==(const AlgebraicSphere< DataPoint, NeighborFilter, T > &other) const
Comparison operator.
This Source Code Form is subject to the terms of the Mozilla Public License, v.