Fitting a Straight Line to 3D Points, and then finding the nearest point to those lines.

637 Views Asked by At

I've been stuck on this problem for over a week now.

Essentially, I have a group of 4 tracks of points from a bunch of detectors in 3 dimensions. I need to map these points to straight lines and then work back to where all 4 lines meet. Obviously, they're not going to meet exactly so I need to do a least squares solution there.

I've only ever done problems like this in 2 dimensions and I'm having a problem translating to 3. There seems to be no information about fitting a least squares line to a set of 3D points - every solution just finds a plane.

So basically I need a way to find a vector line of the form:

 P = a + bt

Where a is a position vector and b the direction vector, and then from that find the nearest point to n number of those lines.