在3D中为3D点数据拟合3D线? [英] Fit a 3D line to 3D point data in Java?

查看:166
本文介绍了在3D中为3D点数据拟合3D线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了相当多的时间试图找到一种简单的方法来做到这一点 - 理想情况下,一个神奇的图书馆存在于那里,它将采用我的3D数据点并在最佳拟合线上返回2点使用正交回归或最小二乘法,并返回拟合线的误差。这样的事情是否存在,如果存在,在哪里?

I've spent a decent amount of time trying to hunt down a simple way of doing this - ideally, a magical library exists out there somewhere that will take my set of 3D data points and return 2 points on the best fit line using either orthogonal regression or least squares and also return the error of the fitted line. Does such a thing exist, and if so, where?

推荐答案

这很容易做到,但要自己写一下将需要特征值求解器或奇异值分解。创建(x-xbar,y-ybar,z-zbar)数据的nx3矩阵A作为列。保存这些列的方法以供日后使用,我将其命名为V0 = [xbar,ybar,zbar]。

This is easy enough to do, but to write it yourself you will need an eigenvalue solver or a singular value decomposition. Create the nx3 matrix A, of your (x-xbar, y-ybar, z-zbar) data as columns. Save those column means for later, I'll call it V0 = [xbar,ybar,zbar].

现在,计算A'* A的特征值和特征向量,即,由A转置形成的3x3矩阵乘以A.

Now, compute the eigenvalues and eigenvectors of A'*A, i.e., the 3x3 matrix formed from A transpose multiplied by A.

如果此数据位于R ^ 3中的一条线上,则其中一个特征值将显着大于另外两个特征值。如果不是这样,则不能很好地估计正交回归线。

If this data lies on a line in R^3, then one of those eigenvalues will be significantly larger than the other two eigenvalues. If this is not true, then the orthogonal regression line will not be well estimated.

获取与A'* A的最大特征值相关联的特征向量。然后,如果V是相应的特征向量,则正交回归线定义为

Take the eigenvector that is associated with the largest eigenvalue of A'*A. Then if V is the corresponding eigenvector, the orthogonal regression line is defined as

V(t)= V0 + t * V

V(t) = V0 + t*V

该行上的任何点都可以通过参数t的某个值给出。

Any point on that line can be given by some value of the parameter t.

或者,计算A的奇异值分解,并采取正确的奇异向量,对应于A的最大奇异值。

Alternatively, compute the singular value decomposition of A, and take the right singular vector which corresponds to the largest singular value of A.

在任何一种情况下,如果你想计算数据点的误差,这将被定义为简单的与相关线的正交距离。

In either event, if you wish to compute the errors for the data points, this would be defined as simply the orthogonal distance to the line in question.

这篇关于在3D中为3D点数据拟合3D线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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