apwidth=800; apheight=600; npoles=2; poles[0]= [ 1,0]; poles[1]= [ 1,0]; nzeros=1; zeros[0]= [-1,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]; } } function circle(){ Colour(Black); LineStart(1,0); for(i=0;i<6.283;i+=.05){ LineTo(Math.cos(i),Math.sin(i)); } } InitGraph(); ScaleWindow(-5,-2.4,1.4,2.4); DrawAxes(); Showroots(); circle(); Colour(Black); for(s[1]=-2.38;s[1]<2.4;s[1]+=ds){ segmid[1]=s[1]; oldgain[1]=0; for(s[0]=-4.98;s[0]<1.4;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]=-4.98;s[0]<1.4;s[0]+=ds){ segmid[0]=s[0]; oldgain[1]=0; for(s[1]=-2.38;s[1]<2.4;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',.2,.5);