# How to convert ellipse from General parametric form to General polar form in MATLAB?

I am facing problem to convert ellipse standard parameters. Everything I say here is refer to http://en.wikipedia.org/wiki/Ellipse

I know what are the General parametric form parameters . Lets call them a,b,φ, tX, tY

Now I need to find the General polar form parameters, Note: not Polar form relative to focus and Polar form relative to center.

The following is my MATLAB code. The upper part plot the figure which is exactly what ellipse I need by using General parametric form. The lower part is my General polar form code . Please help. Thanks

            close all

data = [0.6397 0.9520 15.9195 1.1430 -0.3844];

a = data(1);
b = data(2);
ang = data(3);
tranX = -data(4);
tranY = -data(5);

x = zeros(1,3601);
y = zeros(1,3601);

counter = 1;

for t = 0:.1:360
x(counter) = tranX + a*cosd(t)*cosd(ang) - b*sind(t)*sind(ang);
y(counter) = tranY + a*cosd(t)*sind(ang) + b*sind(t)*cosd(ang);
counter=counter+1;
end

figure;plot(x,y)

%================================

r0 = norm([tranX tranY]);
theta0 = 180+abs(atand(tranY/tranX));
rr  = zeros(1,3601);
counter = 1;
rho = ang;

for t = 0:.1:360
P(counter) = r0*[(b*b-a*a)*cosd(t+theta0-2*rho)+(a*a+b*b)*cosd(t-theta0)];
R(counter) = (b*b-a*a)*cosd(2*t-2*rho)+a*a+b*b;
Q(counter) = sqrt(2)*a*b*sqrt(R(counter)-2*r0*r0*(sind(t-theta0))^2);
rr(counter) = (P(counter)+Q(counter))/R(counter);
counter = counter + 1;
end

[XX,YY] = pol2cart((0:.1:360)*2*pi/180,rr);

figure; plot(XX,YY,'.')

-
 It should be easy to understand the code if you also read en.wikipedia.org/wiki/Ellipse – Marco Mar 6 '12 at 18:50 @Marco: Probably, but then, how much work am I going to do for you if you don't do any work for me in making the question easier to understand? – Jonas Mar 6 '12 at 18:57 Sorry about that. I have a clear explanation in a picture, please download it from sharesend.com/yekfn – Marco Mar 6 '12 at 20:18