Ponca  aa50bfdf187919869239c5b44b748842569114c1
Point Cloud Analysis library
Loading...
Searching...
No Matches
Ponca::AlgebraicSphere< DataPoint, _WFunctor, T > Class Template Reference

Algebraic Sphere primitive. More...

#include <algebraicSphere.h>

+ Inheritance diagram for Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >:
+ Collaboration diagram for Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >:

Public Types

using Scalar = typename DataPoint::Scalar
 Alias to scalar type.
 
using VectorType = typename Base::VectorType
 Alias to vector type.
 
using WFunctor = typename Base::WFunctor
 Alias to weight function.
 

Public Member Functions

AlgebraicSphere< DataPoint, _WFunctor, T > & algebraicSphere ()
 Explicit conversion to AlgebraicSphere , to access methods potentially hidden by heritage.
 
const AlgebraicSphere< DataPoint, _WFunctor, T > & algebraicSphere () const
 Explicit conversion to AlgebraicSphere , to access methods potentially hidden by heritage.
 
void init (const VectorType &_basisCenter=VectorType::Zero())
 Set the scalar field values to 0 and reset the isNormalized() status.
 
bool isValid () const
 Tell if the sphere as been correctly set. Used to set CONFLICT_ERROR_FOUND during fitting.
 
bool operator== (const AlgebraicSphere< DataPoint, WFunctor, T > &other) const
 Comparison operator.
 
bool operator!= (const AlgebraicSphere< DataPoint, WFunctor, T > &other) const
 Comparison operator, convenience function.
 
void changeBasis (const VectorType &newbasis)
 Express the scalar field relatively to a new basis.
 
Scalar prattNorm () const
 compute the Pratt norm of the implicit scalar field.
 
Scalar prattNorm2 () const
 compute the squared Pratt norm of the implicit scalar field.
 
bool applyPrattNorm ()
 Normalize the scalar field by the Pratt norm.
 
Scalar radius () const
 return the estimated radius of the sphere
 
VectorType center () const
 return the estimated center of the sphere
 
bool isNormalized () const
 State indicating when the sphere has been normalized.
 
Scalar potential (const VectorType &_q) const
 Value of the scalar field at the location \( \mathbf{q}\).
 
Scalar potential () const
 Value of the scalar field at the evaluation point.
 
VectorType project (const VectorType &_q) const
 Project a point on the algebraic hypersphere.
 
VectorType projectDescent (const VectorType &_q, int nbIter=16) const
 Project a point on the algebraic hypersphere using Gradient Descent This projection is realized by following the gradient of the hypersphere scalar field.
 
VectorType primitiveGradient (const VectorType &_q) const
 Approximation of the scalar field gradient at \( \mathbf{q}\).
 
const VectorTypeprimitiveGradient () const
 Approximation of the scalar field gradient at the evaluation point.
 
bool isPlane () const
 Used to know if the fitting result to a plane.
 

Public Attributes

Scalar m_uc {0}
 Constant parameter of the Algebraic hyper-sphere.
 
Scalar m_uq {0}
 Quadratic parameter of the Algebraic hyper-sphere.
 
VectorType m_ul {VectorType::Zero()}
 Linear parameter of the Algebraic hyper-sphere.
 

Protected Types

enum  { check = Base::PROVIDES_PRIMITIVE_BASE , PROVIDES_ALGEBRAIC_SPHERE }
 
using Base = T
 Base class of the procedure.
 

Protected Attributes

bool m_isNormalized
 Is the implicit scalar field normalized using Pratt.
 

Detailed Description

template<class DataPoint, class _WFunctor, typename T>
class Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >

Algebraic Sphere primitive.

Method published in [6]

An algebraic hyper-sphere is defined as the \(0\)-isosurface of the scalar field

\( s_\mathbf{u}(\mathbf{x}) = \left[ 1 \; \mathbf{x}^T \; \mathbf{x}^T\mathbf{x}\right]^T \cdot \mathbf{u} \)

with \( \mathbf{u} \left[ u_c \; \mathbf{u_l} \; u_q\right]^T \) is the vector of the constant, linear and quadratic parameters.

Note
If internally the scalar fields are stored in a local frame defined by the evaluation position, the public methods involving a query (such as project, potential, gradient) have to be defined in global coordinates (e.g. you don't need to convert your query in the current locale frame).

This primitive provides:

PROVIDES_ALGEBRAIC_SPHERE 

Definition at line 46 of file algebraicSphere.h.

Member Typedef Documentation

◆ Base

template<class DataPoint , class _WFunctor , typename T >
using Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::Base = T
protected

Base class of the procedure.

Definition at line 48 of file algebraicSphere.h.

◆ Scalar

template<class DataPoint , class _WFunctor , typename T >
using Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::Scalar = typename DataPoint::Scalar

Alias to scalar type.

Definition at line 48 of file algebraicSphere.h.

◆ VectorType

template<class DataPoint , class _WFunctor , typename T >
using Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::VectorType = typename Base::VectorType

Alias to vector type.

Definition at line 48 of file algebraicSphere.h.

◆ WFunctor

template<class DataPoint , class _WFunctor , typename T >
using Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::WFunctor = typename Base::WFunctor

Alias to weight function.

Definition at line 48 of file algebraicSphere.h.

Member Enumeration Documentation

◆ anonymous enum

template<class DataPoint , class _WFunctor , typename T >
anonymous enum
protected
Enumerator
check 

Requires PrimitiveBase.

PROVIDES_ALGEBRAIC_SPHERE 

Provides Algebraic Sphere.

Definition at line 51 of file algebraicSphere.h.

Member Function Documentation

◆ algebraicSphere() [1/2]

template<class DataPoint , class _WFunctor , typename T >
AlgebraicSphere< DataPoint, _WFunctor, T > & Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::algebraicSphere ( )
inline

Explicit conversion to AlgebraicSphere , to access methods potentially hidden by heritage.

Definition at line 68 of file algebraicSphere.h.

◆ algebraicSphere() [2/2]

template<class DataPoint , class _WFunctor , typename T >
const AlgebraicSphere< DataPoint, _WFunctor, T > & Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::algebraicSphere ( ) const
inline

Explicit conversion to AlgebraicSphere , to access methods potentially hidden by heritage.

Definition at line 68 of file algebraicSphere.h.

◆ applyPrattNorm()

template<class DataPoint , class _WFunctor , typename T >
bool Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::applyPrattNorm ( )
inline

Normalize the scalar field by the Pratt norm.

Returns
false when the normalization fails (sphere is already normalized)

Definition at line 164 of file algebraicSphere.h.

◆ center()

template<class DataPoint , class _WFunctor , typename T >
VectorType Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::center ( ) const
inline

return the estimated center of the sphere

Warning
return Vector inf if the fitted surface is planar

Definition at line 204 of file algebraicSphere.h.

◆ changeBasis()

template<class DataPoint , class _WFunctor , typename T >
void Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::changeBasis ( const VectorType newbasis)
inline

Express the scalar field relatively to a new basis.

The sphere in dimension \(d\) is parametrized in the original basis by \(\mathbf{u} = \left[u_c, \mathbf{u}_l^T, u_q\right]^T \in \mathbb{R}^{d+2}\). The sphere equation is given in this basis by:

\begin{equation} u_c + \mathbf{u}_l^T.\mathbf{x} + u_q \mathbf{x}^T.\mathbf{x}= 0 \end{equation}

The same equation written in a different basis is: \begin{equation} u_c + \mathbf{u}_l^T.(\mathbf{x}-\mathbf{\Delta}) + u_q (\mathbf{x}-\mathbf{\Delta})^T.(\mathbf{x}-\mathbf{\Delta})= 0 \end{equation} where \(\mathbf{\Delta}\) is the difference vector between the two basis: \(\mathbf{\Delta} = \mathbf{b}_\mathrm{original}-\mathbf{b}_\mathrm{new}\). It corresponds to a translation of \(\Delta\) of the sphere. This develops in: \begin{equation} \left[u_c - \mathbf{u}_l^T.\mathbf{\Delta} + u_q \mathbf{\Delta}^T.\mathbf{\Delta}\right] + \left[\mathbf{u}_l - 2 u_q \mathbf{\Delta}\right]^T.\mathbf{x} + u_q \mathbf{x}^T.\mathbf{x} = 0 \end{equation}

By identification, the parametrization \(\left[u_c', \mathbf{u}_l'^T, u_q'\right]^T\) of the sphere in the new basis is given by

\(u_c' = u_c - \mathbf{u}_l^T.\mathbf{\Delta} + u_q \mathbf{\Delta}^T.\mathbf{\Delta}\)

\(\mathbf{u}_l' = \mathbf{u}_l - 2 u_q \mathbf{\Delta}\)

\(u_q'=u_q\)

Definition at line 136 of file algebraicSphere.h.

◆ init()

template<class DataPoint , class _WFunctor , typename T >
void Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::init ( const VectorType _basisCenter = VectorType::Zero())
inline

Set the scalar field values to 0 and reset the isNormalized() status.

Warning
Set m_ul to Zero(), which leads to nans in OrientedSphere::normal()

Definition at line 74 of file algebraicSphere.h.

◆ isNormalized()

template<class DataPoint , class _WFunctor , typename T >
bool Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::isNormalized ( ) const
inline

State indicating when the sphere has been normalized.

Definition at line 221 of file algebraicSphere.h.

◆ isPlane()

template<class DataPoint , class _WFunctor , typename T >
bool Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::isPlane ( ) const
inline

Used to know if the fitting result to a plane.

Returns
true if finalize() have been called and the fitting result to a plane

Definition at line 262 of file algebraicSphere.h.

◆ isValid()

template<class DataPoint , class _WFunctor , typename T >
bool Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::isValid ( ) const
inline

Tell if the sphere as been correctly set. Used to set CONFLICT_ERROR_FOUND during fitting.

Returns
false when called straight after init. Should be true after fitting

Definition at line 88 of file algebraicSphere.h.

◆ operator!=()

template<class DataPoint , class _WFunctor , typename T >
bool Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::operator!= ( const AlgebraicSphere< DataPoint, WFunctor, T > &  other) const
inline

Comparison operator, convenience function.

Definition at line 103 of file algebraicSphere.h.

◆ operator==()

template<class DataPoint , class _WFunctor , typename T >
bool Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::operator== ( const AlgebraicSphere< DataPoint, WFunctor, T > &  other) const
inline

Comparison operator.

Warning
Assume that other shares the same basis
See also
changeBasis()

Definition at line 93 of file algebraicSphere.h.

◆ potential() [1/2]

template<class DataPoint , class _WFunctor , typename T >
Scalar Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::potential ( ) const
inline

Value of the scalar field at the evaluation point.

See also
method #isSigned of the fit to check if the sign is reliable

Definition at line 229 of file algebraicSphere.h.

◆ potential() [2/2]

template<class DataPoint , class _WFunctor , typename T >
AlgebraicSphere< DataPoint, _WFunctor, T >::Scalar AlgebraicSphere::potential ( const VectorType _q) const
inline

Value of the scalar field at the location \( \mathbf{q}\).

See also
method #isSigned of the fit to check if the sign is reliable

Definition at line 61 of file algebraicSphere.hpp.

◆ prattNorm()

template<class DataPoint , class _WFunctor , typename T >
Scalar Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::prattNorm ( ) const
inline

compute the Pratt norm of the implicit scalar field.

Definition at line 148 of file algebraicSphere.h.

◆ prattNorm2()

template<class DataPoint , class _WFunctor , typename T >
Scalar Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::prattNorm2 ( ) const
inline

compute the squared Pratt norm of the implicit scalar field.

Definition at line 155 of file algebraicSphere.h.

◆ primitiveGradient() [1/2]

template<class DataPoint , class _WFunctor , typename T >
const VectorType & Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::primitiveGradient ( ) const
inline

Approximation of the scalar field gradient at the evaluation point.

Warning
The gradient is not normalized by default

Definition at line 256 of file algebraicSphere.h.

◆ primitiveGradient() [2/2]

template<class DataPoint , class _WFunctor , typename T >
AlgebraicSphere< DataPoint, _WFunctor, T >::VectorType AlgebraicSphere::primitiveGradient ( const VectorType _q) const
inline

Approximation of the scalar field gradient at \( \mathbf{q}\).

Warning
The gradient is not normalized by default

Definition at line 72 of file algebraicSphere.hpp.

◆ project()

template<class DataPoint , class _WFunctor , typename T >
AlgebraicSphere< DataPoint, _WFunctor, T >::VectorType AlgebraicSphere::project ( const VectorType _q) const
inline

Project a point on the algebraic hypersphere.

This projection is realized in closed-form: the algebraic hypersphere is converted to a geometrical representation (hyperplane or hypersphere), and _q is orthogonally projected on the primtive.

Note
This function is in most cases more accurate and faster than projectDescent

Definition at line 9 of file algebraicSphere.hpp.

◆ projectDescent()

template<class DataPoint , class _WFunctor , typename T >
AlgebraicSphere< DataPoint, _WFunctor, T >::VectorType AlgebraicSphere::projectDescent ( const VectorType _q,
int  nbIter = 16 
) const
inline

Project a point on the algebraic hypersphere using Gradient Descent This projection is realized by following the gradient of the hypersphere scalar field.

Warning
This function is in most cases slower and less accurate than project.
Parameters
_qStarting point
nbIterNumber of iterations (default = 16)

Definition at line 34 of file algebraicSphere.hpp.

◆ radius()

template<class DataPoint , class _WFunctor , typename T >
Scalar Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::radius ( ) const
inline

return the estimated radius of the sphere

Warning
return inf if the fitted surface is planar

Definition at line 182 of file algebraicSphere.h.

Member Data Documentation

◆ m_isNormalized

template<class DataPoint , class _WFunctor , typename T >
bool Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::m_isNormalized
protected

Is the implicit scalar field normalized using Pratt.

Definition at line 59 of file algebraicSphere.h.

◆ m_uc

template<class DataPoint , class _WFunctor , typename T >
Scalar Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::m_uc {0}

Constant parameter of the Algebraic hyper-sphere.

Definition at line 63 of file algebraicSphere.h.

◆ m_ul

template<class DataPoint , class _WFunctor , typename T >
VectorType Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::m_ul {VectorType::Zero()}

Linear parameter of the Algebraic hyper-sphere.

Definition at line 65 of file algebraicSphere.h.

◆ m_uq

template<class DataPoint , class _WFunctor , typename T >
Scalar Ponca::AlgebraicSphere< DataPoint, _WFunctor, T >::m_uq {0}

Quadratic parameter of the Algebraic hyper-sphere.

Definition at line 64 of file algebraicSphere.h.