1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| clear
close all
% Parametre de l'ellipse
a=4;
b=1;
xO = 0;
yO = 0;
ang = 0;
% Point du plan
xM = 5;
yM = 3;
% xM = -4;
% yM = 6;
% Affichage de l'ellipse et du point
figure,
t = 0:.1:2*pi+0.1;
plot(a*cos(t) + xO,b*sin(t) + yO);
hold on,
text(xO,yO,'O');
text(xM,yM,'M');
axis equal,axis([-5 9 -2 7]),grid;
% Calul des coefficients du polynôme :
c4 = -b*yM;
c3 = -2*a*xM-2*a^2+2*b^2;
c2 = 0;
c1 = -2*a*xM+2*a^2-2*b^2;
c0 = b*yM;
% Calcul des solutions :
p = roots([c4 c3 c2 c1 c0]);
for k=1:length(p)
if isreal(p(k))
ang = 2*atan2(p(k),1);
x = a*cos(ang);
y = b*sin(ang);
plot(x,y,'*r');
% Affichage des solutions :
d = sqrt((xM-x)^2+(yM-y)^2);
plot(d*cos(t) + xM,d*sin(t) + yM,'g');
plot([x xM],[y yM],'-');
end
end |
Partager