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?