how to construct a plane from plane coefficients

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how to construct a plane from plane coefficients

icedoggy
Hi there,

i have a plane with holes. For this plane, I determine the coefficients using pcl::SACSegmentation<PointT>. I get the coefficients, for example: 0.506008 -0.862525 -0.00234344 -2.8741 , where they stand for ax + by + cz + d = 0 for the normal point equation of a plane.
I have been knocking my brain out, how to construct a new plane, at the same position as the old one is using these very coeffients.

I have basically determined the min and max positions of my plane (with holes) using     pcl::getMinMax3D(*cloud_filtered, minPt, maxPt);
Then i take a point which I know lies on the plane (I get this from the SACSegmentaiton inliers).
PointT temp;
temp.x = cloud_filtered->points[inliers->indices.at(10)].x;
temp.y = cloud_filtered->points[inliers->indices.at(10)].y;
temp.z = cloud_filtered->points[inliers->indices.at(10)].z;

Then I go through all points within this range of min max and calcualte new x,y,z positions to solve the above plane equation for the new input points. I think this is where I go wrong, but I don't know how to do it right, even after a day of research on the topic plane equation.

for (float x=minPt.x; x<=maxPt.x; x+=0.5f)
        {
          for (float y=minPt.y; y<= maxPt.y; y+=0.5f)
          {
              for(float z=minPt.z; z <= maxPt.z ; z+=0.5f)
              {
                PointT point;
                point.x = coefficients->values[2] * (x - temp.x);
                point.y = coefficients->values[1] * (y - temp.y);
                point.z = coefficients->values[0] * (z - temp.z);
                myPlane->points.push_back (point);
              }
          }
        }

The result is not even a 1 point thick plane (it is more like several points next to each other, red in upper screenshot) but even worse it is at a totally different position (blue in screenshot below, red with green outline is my original cloud with holes).





Can someone please push me into the right direction?
Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: how to construct a plane from plane coefficients

icedoggy
This post was updated on .
okay, i made a mistake in rearranging the normal point equation (Ax+By+Cz=D), dropped the D somehow... (this is not showing in the above code as it really made some nonsense).
So replace the 3 lines in the for-loop by this and it works:

point.x = x;
point.y = -1.0 * (1.0 * coefficients->values[3] + coefficients->values[0] * x + coefficients->values[2] * z  ) / coefficients->values[1] ;
point.z = z;

Maybe someone else finds it useful. Now I get this as a result. Just what I wanted.



and top down its more obvious that they are on top of each other.