来自一组点的 C++ 平面插值 [英] C++ plane interpolation from a set of points

查看:44
本文介绍了来自一组点的 C++ 平面插值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PCL、点云、库使用 C++ 进行编程.

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:

所以我正在做的是通过表面平滑度将点云划分为段(使用 区域增长分割).对于每个段,我想测量表面的准确度,我认为最好的方法是计算最适合表面中点的平面,然后基本上计算点相对于平面的方差(点到平面的距离等).所以我知道 3D 中存在二次或样条插值,但我不太擅长它,我认为应该有一个已经执行它的库.然而,我发现的大多数不计算/返回平面方程,所以我不太确定如何去做.

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.

感谢任何帮助,干杯.

推荐答案

你需要基向量来做这个......所以让 N 成为你的平面法线.要插入您的平面,您需要平面内的 2 个基向量 U,V 和一个属于该平面的起点 P0...

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...

让我们假设我们知道 N,P0,所以 U,V 可以通过利用叉积来计算:

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

其中 u,v 是您的插值标量参数,它们也等于 UP(u,v) 的垂直距离和来自 P0V 方向.

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)

所以不需要二次方程...类似地,如果您需要 u,v 用于某些点 P,您可以这样做:

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)

这篇关于来自一组点的 C++ 平面插值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆