3D最小二乘飞机 [英] 3D Least Squares Plane
问题描述
什么算法,用于计算在(X,Y,Z)空间中的最小二乘平面,给定一组的三维数据点?换句话说,如果我有一堆点像(1,2,3),(4,5,6),(7,8,9),等等,如何将一去计算最合适的飞机˚F (X,Y)=斧+由+ C?什么是算法求A,B和C出一套三维点?
What's the algorithm for computing a least squares plane in (x, y, z) space, given a set of 3D data points? In other words, if I had a bunch of points like (1, 2, 3), (4, 5, 6), (7, 8, 9), etc., how would one go about calculating the best fit plane f(x, y) = ax + by + c? What's the algorithm for getting a, b, and c out of a set of 3D points?
推荐答案
如果您有n个数据点(X [I],Y [I],Z [I]),计算3×3的对称矩阵A的项目有:
If you have n data points (x[i], y[i], z[i]), compute the 3x3 symmetric matrix A whose entries are:
sum_i x[i]*x[i], sum_i x[i]*y[i], sum_i x[i]
sum_i x[i]*y[i], sum_i y[i]*y[i], sum_i y[i]
sum_i x[i], sum_i y[i], n
另外计算3元向量b:
Also compute the 3 element vector b:
{sum_i x[i]*z[i], sum_i y[i]*z[i], sum_i z[i]}
然后解决Ax = b的为给定的a和b。解向量的三个分量是系数的最小二乘拟合平面{A,B,C}
Then solve Ax = b for the given A and b. The three components of the solution vector are the coefficients to the least-square fit plane {a,b,c}.
请注意,这是普通最小二乘适合,这是适当的,只有当z被预期为x和y的线性函数。如果您正在寻找更多的一般在3维空间最佳拟合平面,你可能想了解几何最小二乘。
Note that this is the "ordinary least squares" fit, which is appropriate only when z is expected to be a linear function of x and y. If you are looking more generally for a "best fit plane" in 3-space, you may want to learn about "geometric" least squares.
另请注意,这将失败,如果你的点是在一条线上,因为你的榜样点。
Note also that this will fail if your points are in a line, as your example points are.
这篇关于3D最小二乘飞机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!