C plotting routines for general purpose using postscript subroutine init common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 open(1,file='temp1.ps') C aspect ratio of the paper is 1.4143 write(1,*) '%! Created by Jiro Mizushima' write(1,*) '/Times-Roman findfont 18 scalefont setfont' write(1,*) '/cm {28.35 mul } def ' xsize= 21.0 ysize= 29.7 ysize= 21.0 call viewport(0.2,0.2,0.8,0.8) call xyworld(0.0,0.0,1.0,1.0) call linety(1) call linewidth(1.0) return end subroutine viewport(xv1d,yv1d,xv2d,yv2d) common /viewp/xv1,yv1,xv2,yv2 xv1=xv1d yv1=yv1d xv2=xv2d yv2=yv2d return end subroutine xyworld(xw1d,yw1d,xw2d,yw2d) common /world/xw1,yw1,xw2,yw2 xw1=xw1d yw1=yw1d xw2=xw2d yw2=yw2d return end subroutine fin call stroke write(1,*) ' showpage ' close(1) return end subroutine linety(ichar) if (ichar.eq.1) then write(1,*) '[] 0 setdash' else if (ichar.eq.2) then write(1,*) '[2 2] 0 setdash' else if (ichar.eq.3) then write(1,*) '[8 2] 0 setdash' else if (ichar.eq.4) then write(1,*) '[8 1 1 1] 0 setdash' end if return end subroutine linewidth(w) write(1,*) w,' setlinewidth' return end subroutine setgray(g) write(1,*) g,' setgray' return end subroutine setrgb(r,g,b) write(1,*) r,g,b,' setrgbcolor' return end subroutine newpath write(1,*) ' newpath' return end subroutine closepath write(1,*) ' closepath' return end subroutine stroke write(1,*) ' stroke' return end subroutine fill write(1,*) ' fill' return end subroutine rotate(itheta) write(1,*) itheta,' rotate' return end subroutine scale(tx,ty) write(1,*) tx, ty,' scale' return end subroutine translate(x,y) common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 x1=((x-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize y1=((y-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize write(1,*) x1,' cm ',y1,' cm translate ' return end subroutine clipon(x1,y1,x2,y2) call newpath call plot(x1, y1, 3) call plot(x2, y1, 2) call plot(x2, y2, 2) call plot(x1, y2, 2) write(1,*) 'closepath clip' return end subroutine eoclipon(x1,y1,x2,y2) call newpath call plot(x1, y1, 3) call plot(x2, y1, 2) call plot(x2, y2, 2) call plot(x1, y2, 2) write(1,*) 'closepath eoclip' return end subroutine clipoff write(1,*) 'initclip' return end subroutine plot(x,y,ipen) common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 x1=((x-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize y1=((y-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize if(ipen.eq.3) write(1,*) x1,' cm ',y1,' cm moveto' if(ipen.eq.2) write(1,*) x1,' cm ',y1,' cm lineto' return end subroutine line(x1,y1,x2,y2,g,w,it) call linety(it) call linewidth(w) call setgray(g) call plot(x1, y1, 3) call plot(x2, y2, 2) call stroke call linety(1) call linewidth(1.0) call setgray(0.0) return end subroutine line1(x1,y1,x2,y2) call plot(x1, y1, 3) call plot(x2, y2, 2) call stroke return end subroutine rect(x1,y1,x2,y2,g,w,it) call linety(it) call linewidth(w) call setgray(g) call newpath call plot(x1, y1, 3) call plot(x2, y1, 2) call plot(x2, y2, 2) call plot(x1, y2, 2) call closepath if(g.ne.0.0) write(1,*) ' fill' call stroke call linety(1) call linewidth(1.0) call setgray(0.0) return end subroutine rect1(x1,y1,x2,y2) call newpath call plot(x1, y1, 3) call plot(x2, y1, 2) call plot(x2, y2, 2) call plot(x1, y2, 2) call closepath call stroke return end subroutine rectfill1(x1,y1,x2,y2) call newpath call plot(x1, y1, 3) call plot(x2, y1, 2) call plot(x2, y2, 2) call plot(x1, y2, 2) call closepath write(1,*) ' fill' call stroke return end subroutine circ(x1,y1,r1,g,w,it) common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 xx1=((x1-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy1=((y1-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize rr1=(r1/(xw2-xw1)*(xv2-xv1))*xsize call linety(it) call linewidth(w) call setgray(g) call newpath write(1,*) xx1, ' cm ',yy1, ' cm ',rr1,' cm ', '0 360 arc ' if(g.ne.0.0) write(1,*) ' fill' call stroke call linety(1) call linewidth(1.0) call setgray(0.0) return end subroutine circ1(x1,y1,r1) common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 xx1=((x1-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy1=((y1-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize rr1=(r1/(xw2-xw1)*(xv2-xv1))*xsize call newpath write(1,*) xx1, ' cm ',yy1, ' cm ',rr1,' cm ', '0 360 arc ' call stroke return end subroutine circfill1(x1,y1,r1) common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 xx1=((x1-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy1=((y1-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize rr1=(r1/(xw2-xw1)*(xv2-xv1))*xsize call newpath write(1,*) xx1, ' cm ',yy1, ' cm ',rr1,' cm ', '0 360 arc ' write(1,*) 'fill' call stroke return end subroutine ellipse(x1,y1,rx,ry,g,w,it) call linety(it) call linewidth(w) call setgray(g) call newpath x=x1+rx y=y1 dt=3.14156*2.0/float(20) call plot(x,y,3) do 10 i=1,20 x=x1+rx*cos(dt*i) y=y1+ry*sin(dt*i) call plot(x,y,2) 10 continue call stroke call linety(1) call linewidth(1.0) call setgray(0.0) return end subroutine ellipse1(x1,y1,rx,ry) call newpath x=x1+rx y=y1 dt=3.14156*2.0/float(20) call plot(x,y,3) do 10 i=1,20 x=x1+rx*cos(dt*i) y=y1+ry*sin(dt*i) call plot(x,y,2) 10 continue call stroke return end subroutine ellipsefill1(x1,y1,rx,ry) call newpath x=x1+rx y=y1 dt=3.14156*2.0/float(20) call plot(x,y,3) do 10 i=1,20 x=x1+rx*cos(dt*i) y=y1+ry*sin(dt*i) call plot(x,y,2) 10 continue write(1,*) 'fill' call stroke return end subroutine arc(x1,y1,r1,t1,t2,g,w,it) common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 xx1=((x1-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy1=((y1-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize rr1=(r1/(xw2-xw1)*(xv2-xv1))*xsize call linety(it) call linewidth(w) call setgray(g) call newpath write(1,*) xx1, ' cm ',yy1, ' cm ',rr1,' cm ',t1,t2,' arc ' call stroke call linety(1) call linewidth(1.0) call setgray(0.0) return end subroutine arc1(x1,y1,r1,t1,t2) common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 xx1=((x1-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy1=((y1-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize rr1=(r1/(xw2-xw1)*(xv2-xv1))*xsize call newpath write(1,*) xx1, ' cm ',yy1, ' cm ',rr1,' cm ',t1,t2,' arc ' call stroke return end subroutine curv(x1,y1,x2,y2,x3,y3,x4,y4,g,w,it) common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 xx1=((x1-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy1=((y1-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize xx2=((x2-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy2=((y2-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize xx3=((x3-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy3=((y3-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize xx4=((x4-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy4=((y4-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize call linety(it) call linewidth(w) call setgray(g) call newpath write(1,*) xx1,' cm ',yy1,' cm moveto' write(1,*) xx2,' cm ',yy2,' cm ',xx3,' cm ',yy3,' cm ', & xx4,' cm',yy4,' cm curveto' call stroke call linety(1) call linewidth(1.0) call setgray(0.0) return end subroutine curv1(x1,y1,x2,y2,x3,y3,x4,y4) common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 xx1=((x1-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy1=((y1-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize xx2=((x2-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy2=((y2-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize xx3=((x3-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy3=((y3-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize xx4=((x4-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy4=((y4-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize call newpath write(1,*) xx1,' cm ',yy1,' cm moveto' write(1,*) xx2,' cm ',yy2,' cm ',xx3,' cm ',yy3,' cm ', & xx4,' cm',yy4,' cm curveto' call stroke return end subroutine triangl(x1,y1,r1,a1,g,w,it) common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 xx1=((x1-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy1=((y1-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize rr1=(r1/(xw2-xw1)*(xv2-xv1))*xsize aa1=a1*3.14159/180.0 aa2=aa1+3.14159/3.0 call linety(it) call linewidth(w) call setgray(g) call newpath write(1,*) xx1,' cm ',yy1,' cm moveto ' write(1,*) xx1+rr1*cos(aa1),' cm',yy1+rr1*sin(aa1),' cm lineto ' write(1,*) xx1+rr1*cos(aa2),' cm',yy1+rr1*sin(aa2),' cm lineto ' call closepath if(g.ne.0.0) write(1,*) ' fill' call stroke call linety(1) call linewidth(1.0) call setgray(0.0) return end subroutine triangl1(x1,y1,r1,a1) common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 xx1=((x1-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy1=((y1-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize rr1=(r1/(xw2-xw1)*(xv2-xv1))*xsize aa1=a1*3.14159/180.0 aa2=aa1+3.14159/3.0 call newpath write(1,*) xx1,' cm ',yy1,' cm moveto ' write(1,*) xx1+rr1*cos(aa1),' cm',yy1+rr1*sin(aa1),' cm lineto ' write(1,*) xx1+rr1*cos(aa2),' cm',yy1+rr1*sin(aa2),' cm lineto ' call closepath call stroke return end subroutine trianglfill1(x1,y1,r1,a1) common /paper/xsize,ysize common /viewp/xv1,yv1,xv2,yv2 common /world/xw1,yw1,xw2,yw2 xx1=((x1-xw1)/(xw2-xw1)*(xv2-xv1)+xv1)*xsize yy1=((y1-yw1)/(yw2-yw1)*(yv2-yv1)+yv1)*ysize rr1=(r1/(xw2-xw1)*(xv2-xv1))*xsize aa1=a1*3.14159/180.0 aa2=aa1+3.14159/3.0 call newpath write(1,*) xx1,' cm ',yy1,' cm moveto ' write(1,*) xx1+rr1*cos(aa1),' cm',yy1+rr1*sin(aa1),' cm lineto ' write(1,*) xx1+rr1*cos(aa2),' cm',yy1+rr1*sin(aa2),' cm lineto ' call closepath write(1,*) ' fill' call stroke return end subroutine spline(x1,y1,x2,y2,x3,y3,x4,y4,ipart,g,w,it) ns=10 call linety(it) call linewidth(w) call setgray(g) write(1,*) 'newpath' u=float(ipart) x=-u*(u-1.)*(u-2.)/6.*x1+(u+1.)*(u-1.)*(u-2.)/2.*x2 & -(u+1.)*u*(u-2.)/2.*x3+(u+1.)*u*(u-1.)/6.*x4 y=-u*(u-1.)*(u-2.)/6.*y1+(u+1.)*(u-1.)*(u-2.)/2.*y2 & -(u+1.)*u*(u-2.)/2.*y3+(u+1.)*u*(u-1.)/6.*y4 call plot(x,y,3) do 10 i=1,ns u=float(ipart)+float(i)/float(ns) x=-u*(u-1.)*(u-2.)/6.*x1+(u+1.)*(u-1.)*(u-2.)/2.*x2 & -(u+1.)*u*(u-2.)/2.*x3+(u+1.)*u*(u-1.)/6.*x4 y=-u*(u-1.)*(u-2.)/6.*y1+(u+1.)*(u-1.)*(u-2.)/2.*y2 & -(u+1.)*u*(u-2.)/2.*y3+(u+1.)*u*(u-1.)/6.*y4 call plot(x,y,2) 10 continue call stroke call linety(1) call linewidth(1.0) call setgray(0.0) return end subroutine spline1(x1,y1,x2,y2,x3,y3,x4,y4,ipart) ns=10 write(1,*) 'newpath' u=float(ipart) x=-u*(u-1.)*(u-2.)/6.*x1+(u+1.)*(u-1.)*(u-2.)/2.*x2 & -(u+1.)*u*(u-2.)/2.*x3+(u+1.)*u*(u-1.)/6.*x4 y=-u*(u-1.)*(u-2.)/6.*y1+(u+1.)*(u-1.)*(u-2.)/2.*y2 & -(u+1.)*u*(u-2.)/2.*y3+(u+1.)*u*(u-1.)/6.*y4 call plot(x,y,3) do 10 i=1,ns u=float(ipart)+float(i)/float(ns) x=-u*(u-1.)*(u-2.)/6.*x1+(u+1.)*(u-1.)*(u-2.)/2.*x2 & -(u+1.)*u*(u-2.)/2.*x3+(u+1.)*u*(u-1.)/6.*x4 y=-u*(u-1.)*(u-2.)/6.*y1+(u+1.)*(u-1.)*(u-2.)/2.*y2 & -(u+1.)*u*(u-2.)/2.*y3+(u+1.)*u*(u-1.)/6.*y4 call plot(x,y,2) 10 continue call stroke return end subroutine parabola(x1,y1,x2,y2,x3,y3,g,w,it) u=0.0 ns=20 call linety(it) call linewidth(w) call setgray(g) call newpath x=(u-1.)*(u-2.)/2.*x1-u*(u-2.)*x2+u*(u-1.)/2.*x3 y=(u-1.)*(u-2.)/2.*y1-u*(u-2.)*y2+u*(u-1.)/2.*y3 call plot(x,y,3) do 10 i=1,2*ns u=float(i)/float(ns) x=(u-1.)*(u-2.)/2.*x1-u*(u-2.)*x2+u*(u-1.)/2.*x3 y=(u-1.)*(u-2.)/2.*y1-u*(u-2.)*y2+u*(u-1.)/2.*y3 call plot(x,y,2) 10 continue call stroke call linety(1) call linewidth(1.0) call setgray(0.0) return end subroutine parabola1(x1,y1,x2,y2,x3,y3) u=0.0 ns=20 call newpath x=(u-1.)*(u-2.)/2.*x1-u*(u-2.)*x2+u*(u-1.)/2.*x3 y=(u-1.)*(u-2.)/2.*y1-u*(u-2.)*y2+u*(u-1.)/2.*y3 call plot(x,y,3) do 10 i=1,2*ns u=float(i)/float(ns) x=(u-1.)*(u-2.)/2.*x1-u*(u-2.)*x2+u*(u-1.)/2.*x3 y=(u-1.)*(u-2.)/2.*y1-u*(u-2.)*y2+u*(u-1.)/2.*y3 call plot(x,y,2) 10 continue call stroke return end subroutine arrow(x1,y1,x2,y2,d,g,w) s=sqrt((x2-x1)**2+(y2-y1)**2) alpha=2.2 x3=x2-(x2-x1)/s*d*alpha-(y2-y1)/s*d y3=y2-(y2-y1)/s*d*alpha+(x2-x1)/s*d x4=x2-(x2-x1)/s*d*alpha+(y2-y1)/s*d y4=y2-(y2-y1)/s*d*alpha-(x2-x1)/s*d call linewidth(w) call setgray(g) call plot(x1, y1, 3) call plot(x2, y2, 2) call plot(x2, y2, 3) call plot(x3, y3, 2) call plot(x2, y2, 3) call plot(x4, y4, 2) call stroke call linety(1) call linewidth(1.0) call setgray(0.0) return end subroutine arrow1(x1,y1,x2,y2,d) s=sqrt((x2-x1)**2+(y2-y1)**2) alpha=2.2 x3=x2-(x2-x1)/s*d*alpha-(y2-y1)/s*d y3=y2-(y2-y1)/s*d*alpha+(x2-x1)/s*d x4=x2-(x2-x1)/s*d*alpha+(y2-y1)/s*d y4=y2-(y2-y1)/s*d*alpha-(x2-x1)/s*d call plot(x1, y1, 3) call plot(x2, y2, 2) call plot(x2, y2, 3) call plot(x3, y3, 2) call plot(x2, y2, 3) call plot(x4, y4, 2) call stroke return end subroutine resist(x1,y1,x2,y2,d,w) s=sqrt((x2-x1)**2+(y2-y1)**2) call linewidth(w) dx=(x2-x1)/12.0 dy=(y2-y1)/12.0 ex=-d*dy ey=d*dx call plot(x1, y1, 3) xx=x1+dx+ex yy=y1+dy+ey call plot(xx, yy, 2) do 10 i=1, 5 xx=x1+(i*2+1)*dx+(-1)**i*ex yy=y1+(i*2+1)*dy+(-1)**i*ey call plot(xx, yy, 2) 10 continue call plot(x2, y2, 2) call stroke call linety(1) return end subroutine battery(x1,y1,x2,y2,d,w) s=sqrt((x2-x1)**2+(y2-y1)**2) call linewidth(w) dx=(x2-x1)/3.0 dy=(y2-y1)/3.0 ex=-dy ey=dx call plot(x1, y1, 3) xx=x1+dx yy=y1+dy call plot(xx, yy, 2) call stroke call linewidth(2.0*w) xx=x1+dx+3.0*ex yy=y1+dy+3.0*ey call plot(xx, yy, 3) xx=x1+dx-3.0*ex yy=y1+dy-3.0*ey call plot(xx, yy, 2) call stroke xx=x1+2.0*dx+ex yy=y1+2.0*dy+ey call plot(xx, yy, 3) xx=x1+2.0*dx-ex yy=y1+2.0*dy-ey call plot(xx, yy, 2) call stroke call linewidth(w) call plot(x2, y2, 3) xx=x2-dx yy=y2-dy call plot(xx, yy, 2) call stroke call linety(1) return end subroutine coil(x1,y1,x2,y2,d,n,w) s=sqrt((x2-x1)**2+(y2-y1)**2) call linewidth(w) ex=(x2-x1)/s ey=(y2-y1)/s a=2.0 ds=(s-2.0*d)/(float(n)+0.5) call plot(x1, y1, 3) do 10 i=1, 40*n+20 t=2.0*3.14159*float(i)/40.0 xx=x1+((d-d*cos(t))+t/2.0/3.14159*ds)*ex-a*d*sin(t)*ey yy=y1+((d-d*cos(t))+t/2.0/3.14159*ds)*ey+a*d*sin(t)*ex call plot(xx, yy, 2) 10 continue call stroke call linety(1) return end subroutine text(x,y,n,string) character*80 string call plot(x, y, 3) write(1,*) '(',string(1:n),') show' call stroke return end subroutine textx(x,y,n,string) character*12 string call plot(x, y, 3) write(1,*) -n/2.0*9.0,-3.0/2.0*15.0, ' rmoveto ' write(1,*) '(',string(1:n),') show' return end subroutine texty(x,y,n,string) character*12 string call plot(x, y, 3) write(1,*) -(n+1)*9.0,-1.0/2.0*12.0, ' rmoveto ' write(1,*) '(',string(1:n),') show' return end subroutine setchar(ichar,ip) if (ichar.eq.1) then write(1,*) '/Times-Roman findfont',ip,' scalefont setfont' else if (ichar.eq.2) then write(1,*) '/Times-Bold findfont',ip,' scalefont setfont' else if (ichar.eq.3) then write(1,*) '/Times-Italic findfont',ip,' scalefont setfont' else if (ichar.eq.4) then write(1,*) '/Times-BoldItalic findfont',ip,' scalefont setfont' else if (ichar.eq.5) then write(1,*) '/Helvetica findfont',ip,' scalefont setfont' else if (ichar.eq.6) then write(1,*) '/Helvetica-Bold findfont',ip,' scalefont setfont' else if (ichar.eq.7) then write(1,*) '/Helvetica-Oblique findfont',ip,' scalefont setfont' else if (ichar.eq.8) then write(1,*) '/Helvetica-BoldOblique findfont',ip, & ' scalefont setfont' else if (ichar.eq.9) then write(1,*) '/Courier findfont',ip,' scalefont setfont' else if (ichar.eq.10) then write(1,*) '/Courier-Bold findfont',ip,' scalefont setfont' else if (ichar.eq.11) then write(1,*) '/Courier-Oblique findfont',ip,' scalefont setfont' else if (ichar.eq.12) then write(1,*) '/Courier-BoldOblique findfont',ip, & ' scalefont setfont' else if (ichar.eq.13) then write(1,*) '/Symbol findfont',ip,' scalefont setfont' end if return end