Im trying to write a matlab program that is supposed to find intersection point between one elipse and one crooked elipse.
((x − 4)^2/a^2)+((y-2)^2/2)=1 - equation for elipse
0.4x^2+y^2-xy = 10 - equation for crooked elipse
r = sqrt(10/((0.4*cos(x)^2)+sin(x)^2-cos(x)*sin(x)) - crooked elipse in polar form
fi =-pi:pi/100:pi;
a=4;b=6; % Half axis's
xc=4;yc=2;
xx=xc+a*cos(fi); yy=yc+b*sin(fi);
plot(xx,yy,xc,yc,'x')
grid;
hold on
% Non polar form x^2+y^2-xy = 10
y = sqrt(10./((0.4.*cos(fi).^2)+(sin(fi).^2)-(cos(fi).*sin(fi))));
polar(fi,y)
xstart = [-4 -4]'; % This is just an example, ive tried 100's of start values
iter=0;
x = xstart;
dx = [1 1]';
fel=1e-6;
while norm(dx)>fel & iter<30
f = [(0.4*x(1)).^2+x(2).^2-x(1).*x(2)-10
(((x(1)-4).^2)/a.^2) + (((x(2)-2).^2)/b.^2)-1];
j = [0.8*x(1)-x(2) 2*x(2)-x(1) % Jacobian
2*((x(1)-4)/a.^2) 2*((x(2)-2)/b.^2)];
dx = -j\f;
x=x+dx;
iter=iter+1;
disp([x' dx']);
end
iter
x
plot(x(1),x(2),'o')
The circles on the picture shows my approximated points. As you can see two of the points are correct but the other two is not. Does anyone have an explanation why the the values appear where the ellipses are not intersecting eachother? Ive tried to solve this problem for hours without result. Note that the four points that are shown in the picture are the only results no matter what start value i choose.