Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
fitting irregularly spaced points to ellipses

Subject: fitting irregularly spaced points to ellipses

From: Peter Schreiber

Date: 26 Jan, 2009 21:02:02

Message: 1 of 2

Hi guys,
Does anybody have some experience with fitting points to ellipses? Any hints or comments would be highly appreciated. Would you recommend a least square solution?

Best Regads,
Peter

Subject: fitting irregularly spaced points to ellipses

From: Roger Stafford

Date: 26 Jan, 2009 22:26:02

Message: 2 of 2

"Peter Schreiber" <schreiber.peter15@gmail.com> wrote in message <gll8ca$3tv$1@fred.mathworks.com>...
> Hi guys,
> Does anybody have some experience with fitting points to ellipses? Any hints or comments would be highly appreciated. Would you recommend a least square solution?
>
> Best Regads,
> Peter

  It is necessary to know how many degrees of freedom your ellipse is allowed. If it is totally unconstrained and you have five degrees of freedom, your general ellipse can be expressed as

 A*x^2+B*x*y+C*y^2+D*x+E*y+F = 0

and this can be expressed as a linear problem in least squares of the six coefficients in a homogeneous equation, which can be solved with the singular decomposition function, 'svd'. If the x and y coordinates of the given points are given as two column vectors X and Y, do this:

 M = [X.^2,X.*Y,Y.^2,X,Y,ones(size(X,1),1)];
 [U,S,V] = svd(M);

Then V(:,6) will consist of the desired six coefficients [A;B;C;D;E;F].

  There is no guarantee this conic will turn out to be an ellipse. If a hyperbola or parabola fits better, that is what you will get. You can tell by the sign of the discriminant, B^2-4*A*C. For an ellipse it should be negative.

  Also note that if the points are bunched say near one end of the ellipse, the fit will tend to be somewhat inaccurate, as one would expect. In least squares each point is given an equal weight, so in these circumstances the weighting would be heavily skewed toward that end.

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us