9#include "../../defines.h"
10#include "../concepts.h"
11#include "../../Filters/concepts.h"
13#include PONCA_MULTIARCH_INCLUDE_STD(cmath)
14#include PONCA_MULTIARCH_INCLUDE_CU_STD(limits)
18#define ALGEBRAIC_SPHERE_REQUIREMENTS ProvidesBasketUnitBase<T>&& HasLocalFrame<_NFilter>
45 template <
class DataPo
int,
class _NFilter,
typename T>
46 requires ALGEBRAIC_SPHERE_REQUIREMENTS
49 PONCA_FITTING_DECLARE_DEFAULT_TYPES
70 PONCA_MULTIARCH inline
void init()
75 m_ul = VectorType::Zero();
84 PONCA_MULTIARCH [[nodiscard]]
inline bool isValid()
const
92 return Base::operator==(other) &&
isApprox(other);
96 template <
typename Other>
97 PONCA_MULTIARCH [[nodiscard]]
inline bool isApprox(
98 const Other& other,
const Scalar& epsilon = Eigen::NumTraits<Scalar>::dummy_precision())
const
100 PONCA_MULTIARCH_STD_MATH(pow);
101 const Scalar squaredEpsilon = epsilon * epsilon;
102 return pow(
m_uc - other.uc(),
Scalar(2)) < squaredEpsilon &&
103 pow(
m_uq - other.uq(),
Scalar(2)) < squaredEpsilon &&
104 internal::isApprox(
m_ul, other.ul(),
Scalar(1), epsilon);
110 return !((*this) == other);
147 auto& frame = Base::getNeighborFrame();
150 frame.changeNeighborhoodFrame(newbasis);
160 PONCA_MULTIARCH [[nodiscard]]
inline Scalar uc()
const {
return m_uc; }
166 PONCA_MULTIARCH [[nodiscard]]
inline Scalar uq()
const {
return m_uq; }
171 PONCA_MULTIARCH_STD_MATH(sqrt);
205 PONCA_MULTIARCH_CU_STD_FUNC(numeric_limits);
207 return numeric_limits<Scalar>::infinity();
209 PONCA_MULTIARCH_STD_MATH(sqrt);
214 PONCA_MULTIARCH [[nodiscard]]
inline Scalar kMean()
const
227 PONCA_MULTIARCH_CU_STD_FUNC(numeric_limits);
229 return VectorType::Constant(numeric_limits<Scalar>::infinity());
232 return Base::getNeighborFrame().convertToGlobalBasis((
Scalar(-0.5) * b) *
m_ul);
243 const VectorType lq = Base::getNeighborFrame().convertToLocalBasis(_q);
259 PONCA_MULTIARCH [[nodiscard]]
inline VectorType
project(
const VectorType& _q)
const;
266 const VectorType lq = Base::getNeighborFrame().convertToLocalBasis(_q);
278 PONCA_MULTIARCH [[nodiscard]]
inline bool isPlane()
const
280 PONCA_MULTIARCH_STD_MATH(abs);
281 bool bPlanar = Eigen::internal::isApprox(
m_uq,
Scalar(0));
282 bool bReady = Base::isReady();
283 return bReady && bPlanar;
288 PONCA_MULTIARCH [[nodiscard]]
inline Scalar
potentialLocal(
const VectorType& _lq)
const;
294#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
Scalar potentialLocal(const VectorType &_lq) const
Value of the scalar field at the location .
bool applyPrattNorm()
Normalize the scalar field by the Pratt norm.
VectorType primitiveGradientLocal(const VectorType &_lq) const
Approximation of the scalar field gradient at .
void changeBasis(const VectorType &newbasis)
Express the scalar field relatively to a new basis.
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.
AlgebraicSphere< DataPoint, _NFilter, T > & projectionOperator()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
AlgebraicSphere< DataPoint, _NFilter, T > & implicitPrimitive()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
AlgebraicSphere< DataPoint, _NFilter, T > & meanCurvature()
Explicit conversion to CLASSNAME, to access methods potentially hidden by heritage.
Scalar m_uq
Quadratic parameter of the Algebraic hyper-sphere.
Scalar m_uc
Constant parameter of the Algebraic hyper-sphere.
typename DataPoint::Scalar Scalar
Alias to scalar type.
Scalar uc() const
Constant parameter of the Algebraic hyper-sphere.
AlgebraicSphere< DataPoint, _NFilter, T > & algebraicSphere()
Explicit conversion to CLASSNAME, 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.
VectorType project(const VectorType &_q) const
Project a point on the algebraic hypersphere.
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
Scalar uq() const
Quadratic parameter of the Algebraic hyper-sphere.
VectorType m_ul
Linear parameter of the Algebraic hyper-sphere.
const VectorType & ul() const
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.