npoles=3; poles[0]= [ 0,0]; poles[1]= [-1,0]; poles[2]= [-1,0]; nzeros=0; var ds=.04; var segmid=[0,0]; var dgain=[0,0]; var oldgain=[0,0]; var segment=[0,0]; function Blob(x,c){ Colour(c); BoxFill(x[0]-ds/2,x[1]+ds/2,x[0]+ds/2,x[1]-ds/2); } function Blip(x,c){ Colour(c); BoxFill(x[0]-ds/4,x[1]+ds/4,x[0]+ds/4,x[1]-ds/4); } function Showroots(){ for(i=0;i
0){ segment[0]=ds*dgain[0]/mod; segment[1]=-ds*dgain[1]/mod; }else{ segment=[0,0]; } } InitGraph(); ScaleWindow(-1.6,-1,1.6,1); DrawAxes(); Showroots(); Colour(Black); for(s[1]=-.98;s[1]<1;s[1]+=ds){ segmid[1]=s[1]; oldgain[1]=0; for(s[0]=-1.58;s[0]<1.6;s[0]+=ds){ getgain(s); if((gain[1]*oldgain[1]<0)&&(gain[0]<0)){ csub(dgain,gain,oldgain); getsegment(); segmid[0]=s[0]-ds*gain[1]/dgain[1]; LineStart(segmid[0]-segment[0]/2,segmid[1]-segment[1]/2); LineTo(segmid[0]+segment[0]/2,segmid[1]+segment[1]/2); } copy(gain,oldgain); } } for(s[0]=-1.58;s[0]<1.6;s[0]+=ds){ segmid[0]=s[0]; oldgain[1]=0; for(s[1]=-.98;s[1]<1;s[1]+=ds){ getgain(s); if((gain[1]*oldgain[1]<0)&&(gain[0]<0)){ csub(dgain,gain,oldgain); getsegment(); segmid[1]=s[1]-ds*gain[1]/dgain[1]; LineStart(segmid[0]+segment[1]/2,segmid[1]-segment[0]/2); LineTo(segmid[0]-segment[1]/2,segmid[1]+segment[0]/2); } copy(gain,oldgain); } } Label('Root locus',.5,.5);