36 #ifndef _polygon_primitive_planefitting_CPP_
37 #define _polygon_primitive_planefitting_CPP_
42 #include <CGAL/Cartesian.h>
43 #include <CGAL/linear_least_squares_fitting_3.h>
58 std::list<CGAL::Cartesian<double>::Point_3> points;
60 for (
int i=0; i<(int)pcin->points.size(); i++)
62 points.push_back(CGAL::Cartesian<double>::Point_3(pcin->points[i].x, pcin->points[i].y, pcin->points[i].z));
66 CGAL::Cartesian<double>::Plane_3 pl;
67 double fit_quality = CGAL::linear_least_squares_fitting_3(points.begin(),points.end(),pl,CGAL::Dimension_tag<0>());
70 plane->values[0] = pl.a();
71 plane->values[1] = pl.b();
72 plane->values[2] = pl.c();
73 plane->values[3] = pl.d();
91 std::list<CGAL::Cartesian<double>::Point_3> points;
94 double weight_pcin1 = (1-
ratio)/(
double)pcin1->points.size();
95 double weight_pcin2 = ratio/(double)pcin2->points.size();
103 for (
int i=0; i<(int)pcin1->points.size(); i++)
105 for (
double j=0; j<weight_pcin1; j+=0.00001)
106 points.push_back(CGAL::Cartesian<double>::Point_3(pcin1->points[i].x, pcin1->points[i].y, pcin1->points[i].z));
109 for (
int i=0; i<(int)pcin2->points.size(); i++)
111 for (
double j=0; j<weight_pcin2; j+=0.00001)
112 points.push_back(CGAL::Cartesian<double>::Point_3(pcin2->points[i].x, pcin2->points[i].y, pcin2->points[i].z));
116 CGAL::Cartesian<double>::Plane_3 pl;
117 double fit_quality = CGAL::linear_least_squares_fitting_3(points.begin(),points.end(),pl,CGAL::Dimension_tag<0>());
120 plane->values[0] = pl.a();
121 plane->values[1] = pl.b();
122 plane->values[2] = pl.c();
123 plane->values[3] = pl.d();
double fit_plane_to_two_pc_and_ratio(pcl::PointCloud< pcl::PointXYZ >::Ptr pcin1, pcl::PointCloud< pcl::PointXYZ >::Ptr pcin2, double ratio, pcl::ModelCoefficients::Ptr plane)
fits a plane to two weighted point clouds, given a ratio
A class c_polygon_primitive that contains information about a detected polygon primitive as well as t...
double fit_plane_to_pc(pcl::PointCloud< pcl::PointXYZ >::Ptr pcin, pcl::ModelCoefficients::Ptr plane)
Fits a plane to a point cloud.