Skip to content

Instantly share code, notes, and snippets.

@atandrau
Created February 28, 2011 12:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atandrau/847250 to your computer and use it in GitHub Desktop.
Save atandrau/847250 to your computer and use it in GitHub Desktop.
Compute Planarity of a 3D point using approach 1.
double PointCloud::computePlanarity(int pointIndex) {
PointCloud p;
p.points.push_back(points[pointIndex]);
for (int i = 0; i < (int)points.size(); i++) {
if(i != pointIndex && points[i].distanceTo(points[pointIndex]) <= MaxEPS) {
p.points.push_back(points[i]);
}
}
Plane plane = p.bestFittingPlane();
double dist = 0;
for (int i = 0; i < (int)p.points.size(); i++)
dist += p.points[i].distanceTo(plane);
dist /= p.points.size();
return dist;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment