C++ plane interpolation from a set of points

百般思念 提交于 2019-12-03 00:05:22

问题


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.


回答1:


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)


来源:https://stackoverflow.com/questions/45284267/c-plane-interpolation-from-a-set-of-points

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!