Re: best line through a set of 3D points
- To: mathgroup at smc.vnet.net
- Subject: [mg18733] Re: [mg18386] best line through a set of 3D points
- From: Maarten.vanderBurgt at icos.be
- Date: Sat, 17 Jul 1999 02:36:48 -0400
- Sender: owner-wri-mathgroup at wolfram.com
David, Richard, Jens, Tom, Hartmut,
Thank you all very much for your help.
A solutions which was very elegant and very usefull for me came from Jens.
He suggested to fit a line through the 3 projections on the x-y, y-x and
x-z planes. This imediately gives you the direction vector of a best fit in
3D.
David sent me a nice notebook: the essential part in there is: do not try
to find a direction vector of the type (a, b, c) but try to find e.g. (1,
v, t) = (1, b/a, c/a), and normalize afterwards. This way the least
squares approach by minimizing the sum of the squares of the distances from
the points to the line, also worked: you do get a set of two equations from
which you can get non-trivial solutions for v and t.
again thanks for your help
regards
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
_______________________________________________________________
Maarten.vanderBurgt at icos.be on 30-06-99 08:13:40 PM
Subject: [mg18733] [mg18386] best line through a set of 3D points
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
_______________________________________________________________