5#include "point_cloud/plane_estimator.h"
10#include "common/macros.h"
13 namespace point_cloud {
15 RSMESH_ASSERT(points.rows() >= 3);
17 auto n_points = points.rows();
19 auto svd = pca_svd(points);
20 auto s0 = svd.singularValues()(0);
21 auto s1 = svd.singularValues()(1);
22 auto s2 = svd.singularValues()(2);
24 point_err_ = std::sqrt(s0 * s0 + s1 * s1 + s2 * s2) / std::sqrt(n_points);
25 line_err_ = std::hypot(s1, s2) / std::sqrt(n_points);
26 plane_err_ = std::abs(s2) / std::sqrt(n_points);
29 plane_factor_ = std::numeric_limits<double>::quiet_NaN();
30 }
else if(s1 == 0.0) {
32 }
else if(s2 == 0.0) {
33 plane_factor_ = std::numeric_limits<double>::infinity();
35 plane_factor_ = line_err_ * line_err_ / (plane_err_ * point_err_);
38 basis_ = svd.matrixV();
41 double plane_estimator::line_error()
const {
45 double plane_estimator::plane_factor()
const {
53 double plane_estimator::plane_error()
const {
57 double plane_estimator::point_error()
const {
61 Eigen::JacobiSVD<Eigen::MatrixXd> plane_estimator::pca_svd(
const geometry::points3d &points) {
63 return Eigen::JacobiSVD<Eigen::MatrixXd>(points.rowwise() - barycenter, Eigen::ComputeThinV);
Eigen::RowVector3d vector3d
3维向量
本系统的主命名空间,包含了common, examples, fmm, geometry, numeric, point_cloud等子命名空间