best line through a set of 3D points

*To*: mathgroup at smc.vnet.net*Subject*: [mg18386] best line through a set of 3D points*From*: Maarten.vanderBurgt at icos.be*Date*: Wed, 30 Jun 1999 14:13:40 -0400*Sender*: owner-wri-mathgroup at wolfram.com

Dear all, This is not strictly a mathematica question but someone might have a solution in the form of a mathematica function or so. I have a set of 3d points, DATA = {{x1,y1,z1},{x2,y2,z3},...}, roughly occupying a sigar shaped volume in the 3D space. I want to find the line that best fits these points. I tried a least squares approach: I assumed the line was going through the average off all the points in DATA and then I tried to find a vector in the direction of the line by minimizing the sum of the squares of the distances from the points to the line. For some reason I end up with a set of 3 equations which only solution is (0,0,0). There is probably some sensible reason for this but I did not manage to figure out why. Maybe someone else knows? Another approach I tried is averaging the vectors connecting each point in DATA with the average point of DATA. This average vector could be a good direction for the best line. But comparing this method in two dimensions with a least squares fit, I noticed the agreement is not always good. So I am not sure whether this is the best method. Does anyone have a solution to this problem or can anyone point me to some resources (book(s), web page(s)) where I could find a solution. thanks a lot Maarten _______________________________________________________________ Maarten van der Burgt ICOS Vision Systems Esperantolaan 9 B-3001 Leuven, Belgium tel. + 32 16 398220; direct + 32 16 398316; fax. + 32 16 400067 e-mail: maarten.vanderburgt at icos.be _______________________________________________________________