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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
clc;clear;close all;
z1=[32,45]; z2=[355,126]; z3=[194,445];
z12=(z1+z2)/2;z23=(z3+z2)/2;z31=(z3+z1)/2;
LinePlot=@(p1,p2) line([p1(1),p2(1)],[p1(2),p2(2)],... 'color','k','linewidth',2); ZP=@(z) [real(z),imag(z)]; PZ1=@(p1) p1(1) + p1(2)*1i; PZ2=@(p1) [PZ1(p1)^3,PZ1(p1)^2,PZ1(p1)]; dist=@(p1,p2) norm(p1-p2);
zz1=PZ1(z1);zz2=PZ1(z2);zz3=PZ1(z3);
mat=[PZ2(z1);PZ2(z2);PZ2(z3)]; abc=mat\[-1;-1;-1];a=abc(1);b=abc(2);c=abc(3);
fp=roots([3*a,2*b,c]); fp1=ZP(fp(1));fp2=ZP(fp(2));
zp=-b/3/a; zp1=ZP(zp);
A=(dist(fp1,z12)+dist(fp2,z12))/2; C=dist(fp1,fp2)/2; B=sqrt(A^2-C^2); E=C/A; temp=fp1-fp2;gamma=atan(temp(2)/temp(1)); Zmat=[cos(gamma),-sin(gamma); sin(gamma), cos(gamma)];
theta=-0.01:0.01:2*pi; x0=A*cos(theta);y0=B*sin(theta); temp=Zmat*[x0;y0]+zp1';x=temp(1,:);y=temp(2,:);
figure(1);axis equal;axis off;box off;hold on; figset([10,10,0.2,0.2],[1,0.9,0,-0.01]); LinePlot(z1,z2);LinePlot(z2,z3);LinePlot(z3,z1); plot(x,y,'color',[0.55,0.94,0.53],'linewidth',2);
plot(z1(1),z1(2),'bo','MarkerFaceColor','b','Markersize',7); plot(z2(1),z2(2),'bo','MarkerFaceColor','b','Markersize',7); plot(z3(1),z3(2),'bo','MarkerFaceColor','b','Markersize',7);
c1=[0.21,0.77,0.18]; plot(z12(1),z12(2),'o','color',c1,'MarkerFaceColor',c1,'Markersize',7); plot(z23(1),z23(2),'o','color',c1,'MarkerFaceColor',c1,'Markersize',7); plot(z31(1),z31(2),'o','color',c1,'MarkerFaceColor',c1,'Markersize',7);
plot(fp1(1),fp1(2),'ro','MarkerFaceColor','r','Markersize',7); plot(fp2(1),fp2(2),'ro','MarkerFaceColor','r','Markersize',7);
b1=[0.93,0.69,0.13]; plot(zp1(1),zp1(2),'o','color',b1,'MarkerFaceColor',b1,'Markersize',7);
str='$az^3+bz^2+cz+d=0$'; text('Interpreter','latex','String',str,'HorizontalAlignment','center',... 'Units','normalized','Position',[0.5,1.1],'fontsize',16);
function figset(parameter1,parameter2)
set(0,'units','centimeters') cm_ss=get(0,'screensize'); W=cm_ss(3); H=cm_ss(4);
temp1=[parameter1(3),parameter1(4),parameter1(1)/W,parameter1(2)/H]; set(gcf,'units','normalized','position',temp1); if nargin==2 temp2=[parameter2(3),parameter2(4),parameter2(1),parameter2(2)]; set(gca,'position',temp2); end
end
|