9#include "../../defines.h"
10#include "../concepts.h"
14#define HEIGHT_FIELD_REQUIREMENTS Is3D<DataPoint>
15#define QUADRATIC_HEIGHT_FIELD_REQUIREMENTS ProvidesHeightFieldBase<T>
27 template <
class DataPo
int,
class _NFilter,
typename T>
28 requires HEIGHT_FIELD_REQUIREMENTS
31 PONCA_FITTING_DECLARE_DEFAULT_TYPES
50 return *(
_lq.data() + 1);
56 return *(
_lq.data() + 1);
62 return *(
_lq.data() + 2);
68 return *(
_lq.data() + 2);
80 template <
class DataPo
int,
class _NFilter,
typename T>
81 requires QUADRATIC_HEIGHT_FIELD_REQUIREMENTS
84 PONCA_FITTING_DECLARE_DEFAULT_TYPES
85 using HeightFieldCoefficients = Eigen::Matrix<Scalar, 6, 1>;
86 static_assert(DataPoint::Dim == 3,
"QuadraticHeightField is only valid in 3D");
90 HeightFieldCoefficients
m_coeffs{HeightFieldCoefficients::Zero()};
102 PONCA_MULTIARCH [[
nodiscard]]
inline const HeightFieldCoefficients& coeffs()
const {
return m_coeffs; }
105 PONCA_MULTIARCH
inline void init()
116 return !
m_coeffs.isApprox(HeightFieldCoefficients::Zero());
119 PONCA_MULTIARCH [[
nodiscard]]
inline bool operator==(
129 return !((*this) ==
other);
135 return h_uu() *
u *
u + h_vv() *
v *
v + h_uv() *
u *
v + h_u() *
u + h_v() *
v + h_c();
138 PONCA_MULTIARCH [[
nodiscard]]
inline const Scalar& h_uu()
const {
return *(
m_coeffs.data()); }
139 PONCA_MULTIARCH [[nodiscard]]
inline const Scalar& h_vv()
const {
return *(
m_coeffs.data() + 1); }
140 PONCA_MULTIARCH [[nodiscard]]
inline const Scalar& h_uv()
const {
return *(
m_coeffs.data() + 2); }
141 PONCA_MULTIARCH [[nodiscard]]
inline const Scalar& h_u()
const {
return *(
m_coeffs.data() + 3); }
142 PONCA_MULTIARCH [[nodiscard]]
inline const Scalar& h_v()
const {
return *(
m_coeffs.data() + 4); }
143 PONCA_MULTIARCH [[nodiscard]]
inline const Scalar& h_c()
const {
return *(
m_coeffs.data() + 5); }
148 return Scalar(2) * h_uu() *
u + h_uv() *
v + h_u();
154 return Scalar(2) * h_vv() *
v + h_uv() *
u + h_v();
160 return Scalar(2) * h_uu();
166 return Scalar(2) * h_vv();
177 PONCA_MULTIARCH [[nodiscard]]
inline VectorType heightTangentULocal(
const VectorType& _localQ)
const
179 const Scalar tu =
dh_du(Base::getUFromLocalCoordinates(_localQ), Base::getVFromLocalCoordinates(_localQ));
184 PONCA_MULTIARCH [[nodiscard]]
inline VectorType heightTangentVLocal(
const VectorType& _localQ)
const
186 const Scalar tv =
dh_dv(Base::getUFromLocalCoordinates(_localQ), Base::getVFromLocalCoordinates(_localQ));
201 template <
class DataPo
int,
class _NFilter,
typename T>
202 requires QUADRATIC_HEIGHT_FIELD_REQUIREMENTS
205 PONCA_FITTING_DECLARE_DEFAULT_TYPES
206 using HeightFieldCoefficients = Eigen::Matrix<Scalar, 4, 1>;
207 static_assert(DataPoint::Dim == 3,
"QuadraticHeightField is only valid in 3D");
211 HeightFieldCoefficients
m_coeffs{HeightFieldCoefficients::Zero()};
223 PONCA_MULTIARCH [[
nodiscard]]
inline const HeightFieldCoefficients& coeffs()
const {
return m_coeffs; }
226 PONCA_MULTIARCH
inline void init()
237 return !
m_coeffs.isApprox(HeightFieldCoefficients::Zero());
240 PONCA_MULTIARCH [[
nodiscard]]
inline bool operator==(
250 return !((*this) ==
other);
254 template <
typename Other>
256 const Other&
other,
const Scalar& epsilon = Eigen::NumTraits<Scalar>::dummy_precision())
const
264 return h_uu() *
u *
u + h_vv() *
v *
v + h_uv() *
u *
v + h_c();
267 PONCA_MULTIARCH [[
nodiscard]]
inline const Scalar& h_uu()
const {
return *(
m_coeffs.data()); }
268 PONCA_MULTIARCH [[nodiscard]]
inline const Scalar& h_vv()
const {
return *(
m_coeffs.data() + 1); }
269 PONCA_MULTIARCH [[nodiscard]]
inline const Scalar& h_uv()
const {
return *(
m_coeffs.data() + 2); }
270 PONCA_MULTIARCH [[nodiscard]]
inline const Scalar& h_c()
const {
return *(
m_coeffs.data() + 3); }
275 return Scalar(2) * h_uu() *
u + h_uv() *
v;
281 return Scalar(2) * h_vv() *
v + h_uv() *
u;
287 return Scalar(2) * h_uu();
293 return Scalar(2) * h_vv();
304 PONCA_MULTIARCH [[nodiscard]]
inline VectorType heightTangentULocal(
const VectorType& _localQ)
const
306 const Scalar tu =
dh_du(Base::getUFromLocalCoordinates(_localQ), Base::getVFromLocalCoordinates(_localQ));
311 PONCA_MULTIARCH [[nodiscard]]
inline VectorType heightTangentVLocal(
const VectorType& _localQ)
const
313 const Scalar tv =
dh_dv(Base::getUFromLocalCoordinates(_localQ), Base::getVFromLocalCoordinates(_localQ));
Aggregator class used to declare specialized structures using CRTP.
Internal base classe for height fields.
HeightField< DataPoint, _NFilter, T > & heightFieldBase()
Explicit conversion to HeightField , to access methods potentially hidden by heritage.
Scalar & getVFromLocalCoordinates(VectorType &_lq)
get access to v from local coordinate vector
const Scalar & getVFromLocalCoordinates(const VectorType &_lq) const
get access to v from local coordinate vector
typename DataPoint::Scalar Scalar
Alias to scalar type.
Scalar & getUFromLocalCoordinates(VectorType &_lq) const
get access to u from local coordinate vector
typename Base::VectorType VectorType
Alias to vector type.
const Scalar & getHFromLocalCoordinates(const VectorType &_lq) const
get access to height from local coordinate vector
Scalar & getHFromLocalCoordinates(VectorType &_lq) const
get access to height from local coordinate vector
const Scalar & getUFromLocalCoordinates(const VectorType &_lq) const
get access to u from local coordinate vector
Quadratic height field defined as .
typename Base::VectorType VectorType
Alias to vector type.
QuadraticHeightField< DataPoint, _NFilter, T > & heightField()
Explicit conversion to QuadraticHeightField , to access methods potentially hidden by heritage.
void setQuadric(const HeightFieldCoefficients &coeffs)
Set the scalar field values.
typename DataPoint::Scalar Scalar
Alias to scalar type.
void init()
Set the scalar field values to 0.
bool isValid() const
Tell if the plane as been correctly set. Used to set CONFLICT_ERROR_FOUND during fitting.
HeightFieldCoefficients m_coeffs
Quadric parameters, stored as .
QuadraticHeightField()
Default constructor.
Scalar dh_du(Scalar u=Scalar(0), Scalar v=Scalar(0)) const
Partial derivative .
T Base
Base class of the procedure.
Scalar dh_dv(Scalar u=Scalar(0), Scalar v=Scalar(0)) const
Partial derivative .
Scalar d2h_dvv(Scalar u=Scalar(0), Scalar v=Scalar(0)) const
Second order partial derivative .
bool operator!=(const QuadraticHeightField< DataPoint, _NFilter, T > &other) const
Comparison operator, convenience function.
Scalar height(Scalar u, Scalar v) const
Height value at local uv.
QuadraticHeightField< DataPoint, _NFilter, T > & quadraticHeightField()
Explicit conversion to QuadraticHeightField , to access methods potentially hidden by heritage.
Scalar d2h_duu(Scalar u=Scalar(0), Scalar v=Scalar(0)) const
Second order partial derivative .
Quadratic height field defined as .
Scalar d2h_dvv(Scalar u=Scalar(0), Scalar v=Scalar(0)) const
Second order partial derivative .
Scalar d2h_duu(Scalar u=Scalar(0), Scalar v=Scalar(0)) const
Second order partial derivative .
Scalar dh_du(Scalar u=Scalar(0), Scalar v=Scalar(0)) const
Partial derivative .
void setQuadric(const HeightFieldCoefficients &coeffs)
Set the scalar field values.
Scalar dh_dv(Scalar u=Scalar(0), Scalar v=Scalar(0)) const
Partial derivative .
Scalar height(Scalar u, Scalar v) const
Height value at local uv.
T Base
Base class of the procedure.
RestrictedQuadraticHeightField()
Default constructor.
QuadraticHeightField< DataPoint, _NFilter, T > & heightField()
Explicit conversion to QuadraticHeightField , to access methods potentially hidden by heritage.
bool isApprox(const Other &other, const Scalar &epsilon=Eigen::NumTraits< Scalar >::dummy_precision()) const
Approximate comparison operator operator.
void init()
Set the scalar field values to 0.
RestrictedQuadraticHeightField< DataPoint, _NFilter, T > & quadraticHeightField()
Explicit conversion to RestrictedQuadraticHeightField , to access methods potentially hidden by herit...
bool isValid() const
Tell if the plane as been correctly set. Used to set CONFLICT_ERROR_FOUND during fitting.
typename DataPoint::Scalar Scalar
Alias to scalar type.
HeightFieldCoefficients m_coeffs
Quadric parameters, stored as .
bool operator!=(const RestrictedQuadraticHeightField< DataPoint, _NFilter, T > &other) const
Comparison operator, convenience function.
typename Base::VectorType VectorType
Alias to vector type.
This Source Code Form is subject to the terms of the Mozilla Public License, v.