Point Cloud Library (PCL)  1.12.0
mls_calculatePrincipalCurvatures.hpp
1 Eigen::Vector2f
2 pcl::MLSResult::calculatePrincipalCurvatures (const double u, const double v) const
3 {
4  Eigen::Vector2f k (1e-5, 1e-5);
5 
6  // Note: this use the Monge Patch to derive the Gaussian curvature and Mean Curvature found here http://mathworld.wolfram.com/MongePatch.html
7  // Then:
8  // k1 = H + sqrt(H^2 - K)
9  // k2 = H - sqrt(H^2 - K)
10  if (order > 1 && c_vec.size () >= (order + 1) * (order + 2) / 2 && std::isfinite (c_vec[0]))
11  {
13  const double Z = 1 + d.z_u * d.z_u + d.z_v * d.z_v;
14  const double Zlen = std::sqrt (Z);
15  const double K = (d.z_uu * d.z_vv - d.z_uv * d.z_uv) / (Z * Z);
16  const double H = ((1.0 + d.z_v * d.z_v) * d.z_uu - 2.0 * d.z_u * d.z_v * d.z_uv + (1.0 + d.z_u * d.z_u) * d.z_vv) / (2.0 * Zlen * Zlen * Zlen);
17  const double disc2 = H * H - K;
18  assert (disc2 >= 0.0);
19  const double disc = std::sqrt (disc2);
20  k[0] = H + disc;
21  k[1] = H - disc;
22 
23  if (std::abs (k[0]) > std::abs (k[1])) std::swap (k[0], k[1]);
24  }
25  else
26  {
27  PCL_ERROR ("No Polynomial fit data, unable to calculate the principal curvatures!\n");
28  }
29 
30  return (k);
31 }
@ K
Definition: norms.h:54
Data structure used to store the MLS polynomial partial derivatives.
Definition: mls.h:70
double z_uv
The partial derivative d^2z/dudv.
Definition: mls.h:76
double z_u
The partial derivative dz/du.
Definition: mls.h:72
double z_uu
The partial derivative d^2z/du^2.
Definition: mls.h:74
double z_vv
The partial derivative d^2z/dv^2.
Definition: mls.h:75
double z_v
The partial derivative dz/dv.
Definition: mls.h:73
Eigen::VectorXd c_vec
The polynomial coefficients Example: z = c_vec[0] + c_vec[1]*v + c_vec[2]*v^2 + c_vec[3]*u + c_vec[4]...
Definition: mls.h:229
PolynomialPartialDerivative getPolynomialPartialDerivative(const double u, const double v) const
Calculate the polynomial's first and second partial derivatives.
Definition: mls.hpp:492
Eigen::Vector2f calculatePrincipalCurvatures(const double u, const double v) const
Calculate the principal curvatures using the polynomial surface.
int order
The order of the polynomial.
Definition: mls.h:232