3D vectors intersection using least-squares approa

2019-07-28 01:57发布

问题:

I have been trying to get the intersection point of some 3D lines. The lines are represented in the form

Line: s + t*r. The lines doesn't really intersect, so I would like to get the point in 3D that the distance from that point to all lines is minimum

I found solutions for finding the intersection between two lines, but in my case, it is a set of lines, like 5 or more.

I found a solution that represents the distance between the point a to line l: p+t*r (p is the start point, and r is the direction vector, t is a scalar value) as

d(a,l) = (|| r x (p-a) ||)/|| r || =

|| ([r]x/||r||)a - ([r]x/||r||) p ||

which the solution said that the second equation is a least-square minimization problem of the form

|| Ax-b ||

and the solution is x = (At A)^-1 * At*b , At is A transpose, but I can't format it here.

How can I write the matrix A and vector b if i have several lines?

回答1:

I used the MATLAB function for least-squares n-line intersection here and coded it in C++ for my uses: http://www.mathworks.com/matlabcentral/fileexchange/37192-intersection-point-of-lines-in-3d-space/content/lineIntersect3D.m

I followed the theory for n-line intersection here: http://en.wikipedia.org/wiki/Line-line_intersection

Works great!