
Originally Posted by
Optiminimal
Okey, here comes the extended question:
I want to choose the parameters of an ellipse so that it fits some given points the best. An algebraic solution is far too complex (involving 1000s of terms), so a numerical solution is the way to go.
There are several ways to parameterize an ellipse, lets look at this one:
x = ox + a*Cos(t)*Cos(T) + b*Sin(t)*Sin(T)
y = oy - a*Cos(t)*Sin(T) + b*Sin(t)*Cos(T)
where:
{x;y} is a point on the perimeter of the ellipse.
{ox;oy} is the origo, or center, of the ellipse.
a is the semi-major axis.
b is the semi-minor axis (which is major and minor doesn't matter, I think).
T is the tilt of the ellipse, the angle of the a-axis to the x-axis, say.
t is, well, it is not really a parameter but an angle 0 to 2pi which kind of represents each point on the ellipse. t=0 and t=pi represents two opposite points on the ellipse. I can't explain it well, but it doesn't matter.
Now I have the coordinated of a number of observed points {x1;y1},{x2;y2}...{xn;yn} which are supposed to lie close to the edge of an ellipse. So I want to choose the parameters ox, oy, a, b and T so that the sum of squared differences between the observed points and the closest calculated points is minimized.
First, I will choose a set of values for the parameters ox, oy, a, b and T (I will have good first guess).
Then I will choose one of the observed points {x1;y1}.
Then I will search for the value for t, 0<t<2pi, which minimizes:
SQRT( (x-x1)^2 + (y-y1)^2 ).
Then I will do the same with the next point {x2;y2}.
When this has been done for all n points, I will calculate the sum of the squared distances for all points for the set of parameter values used.
Then it is time to change the parameters ox, oy, a, b and T and do it all over again. And it is here I need some help.
If I had only one parameter, I could easily use for example Newton Raphson. But now that I need 5 parameters, how should I do?
I can formulate any necessary derivative, no problem.
I hope I have made an intelligable post here, and that the thing with the t-value and the extra minimization which it requires, hasn't obscured my real problem, which has to do with how to apply numerical solution methods to an expression with more than one unknown.