-1

I am programming in C++ with the PCL, point cloud, library.

My problem is: computing the variance of some of the points but only with respect to the perpendicular axis with respect to the plane. I will explain myself:

So what I am doing is dividing the point cloud into segments by surface smoothness (with region growing segmentation). For each segment I would like to have a measurement of how accurate the surface is, and I thougth the best way was to compute the plane that best fits the points in the surface and then basically compute the variance of the points with respect to the plane (distance from the point to the plane, etc). So I know there exists the quadratic or spline interpolation in 3D, but I am not so good at it and I thougth there should be a library that aldready performs it. However most of the ones I found do not compute/return the plane equation, so I am not so sure how to do it.

Any help is appreciated, cheers.

  • Do you mean a *least-squares plane*? If so this post could be of help: https://stackoverflow.com/questions/1400213/3d-least-squares-plane – meowgoesthedog Jul 24 '17 at 15:20

1 Answers1

0

you need basis vectors for this ... so let N be your plane normal. To interpolate your plane you need 2 basis vectors U,V inside your plane and one start point P0 belonging to that plane...

Lets assume we know N,P0 so the U,V can be computed by exploiting cross product:

// U is any vector non parallel to N
U = (1.0,0.0,0.0)
if (|dot(U,N)|>0.75) U = (0.0,1.0,0.0)
// make U,V perpendicular to N and each other
V = cross(N,U)
U = cross(V,N)
// normalize U,V,N
U = U/|U|
V = V/|V|
N = N/|N|

Now any point on plane can be interpolated like this:

P(u,v) = P0 + u*U + v*V

Where u,v are your interpolation scalar parameters which are also equal to perpendicular distance of P(u,v) in U and V directions from P0.

To evaluate the distance of your point from the plane (altitude) you can simply do this

alt = dot(N,P(u,v)-P0)

so no quadratics is needed ... Similarly if you need the u,v for some point P you can do this:

u = dot(U,P-P0)
v = dot(V,P-P0)
Spektre
  • 49,595
  • 11
  • 110
  • 380
  • Now that I am trying to do it. I am not sure that this is what I needed or if i understood your answer. Is this computation of the plane giving me the best plane fitting my set of points? Because I dont see any use for the set of points. Or is it that, if i compute this plane, then i can compare the variation of the distances of all the points to the plane? Is this last actually comparable with other plane variations? – Adrián Arroyo Perez Aug 15 '17 at 17:52
  • @AdriánArroyoPerez no this is just the interpolation part. to fit the plane you need to guess/choose `N` so the selected property has minimal error/distance. To do that you can select 3 points and compute normal `Ni` from it via cross product... do this for `m` triples of points (either random or all combinations or what ever) an average `Ni` to `N` or compute normal for most distant 3 points instead. That will closely guess the normal. Now you can try small distortions around it and remember the best fit for example with [approximation search](https://stackoverflow.com/a/36163847/2521214) – Spektre Aug 17 '17 at 18:15