Web pdp-10.trailing-edge.com

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/23/cosysf.sim
There is 1 other file named cosysf.sim in the archive. Click here to see a list.
```OPTIONS(/e);
EXTERNAL CLASS figure;

COMMENT: This procedure will construct a coordinate system
suitable for a figure within the limits xmin,xmax
and ymin,ymax along x- and y-axis respectively.

Version 2, march 1975
Author: Ake Blomberg, FOA, Sweden.                ;

REF(figure) PROCEDURE cosysfor(xmin,xmax,ymin,ymax);
REAL xmin,xmax,ymin,ymax;
BEGIN

REAL xleft,yleft,xlift,yshift,sx,sy,xstep,ystep,ox,oy,temp;
INTEGER i,zerox,zeroy,xtics,ytics;
TEXT labe;
REF(figure) c;

PROCEDURE axis (min,max,metric,left,tics,scale,ztep,zeropos);
NAME left,tics,scale,ztep,zeropos;
REAL min,max,metric,left,scale,ztep;
INTEGER tics,zeropos;

BEGIN
REAL width,right,bigleft,bigright,bigztep,p10,b10,a;
INTEGER nleft,nright,nbig,i,p;
width:=max-min;
p:=Entier(Ln(width)/Ln(10));
p10:=10**p; a:=width/p10; b10:=10*p10;
ztep:= IF a<=2 THEN 0.2*p10 ELSE IF a<=6 THEN 0.5*p10 ELSE p10;
nleft:=Entier(min/ztep); nright:=Entier(max/ztep)+1;
IF Abs(nleft-nright) >= 4 THEN
BEGIN
IF a>2 AND a<=6 AND Mod(nleft,2) NE 0 THEN nleft:=nleft-1;
IF a>2 AND a<=6 AND Mod(nright,2) NE 0 THEN nright:=nright+1;
END;
left:=nleft*ztep; right:=nright*ztep;
bigztep:=IF a<=5 THEN p10 ELSE b10; nbig:=Entier(left/bigztep);
bigleft:=nbig*bigztep;
IF left-bigleft <= ztep THEN left:=bigleft;
bigright:=bigleft+bigztep;
IF bigright>right AND bigright<=right+ztep THEN
right:=bigright;
width:=right-left;
nleft:=Entier(left/ztep); nright:=Entier(right/ztep);
scale:=metric/width; ztep:=scale*ztep;
zeropos:=IF min*max > 0 THEN -1  ELSE -nleft;
tics:=Abs(nleft-nright)+1;
END***axis***;
labe:-Blanks(10);

axis(xmin,xmax,750,xleft,xtics,sx,xstep,zerox);
axis(ymin,ymax,500,yleft,ytics,sy,ystep,zeroy);

xlift:=IF zeroy>=0 THEN 200+zeroy*ystep  ELSE 200;
yshift:=IF zerox>=0 THEN 150+zerox*xstep  ELSE 150;
ox:=150-sx*xleft; oy:=200-sy*yleft;

c:-NEW figure;
c.moveto(yshift,700); c.drawto(yshift,200);
c.moveto(150,xlift); c.drawto(900,xlift);

temp:=200-ystep;
FOR i:=1 STEP 1 UNTIL ytics DO
BEGIN temp:=temp+ystep;
c.moveto(yshift+4,temp); c.drawto(yshift-4,temp);
END;

temp:=150-xstep;
FOR i:=1 STEP 1 UNTIL xtics DO
BEGIN temp:=temp+xstep;
c.moveto(temp,xlift+4); c.drawto(temp,xlift-4);
END;
c.moveto(180,110);
c.write("x-axis:  y=");  labe.Setpos(1);
IF zeroy >=0 THEN labe.Putchar('0') ELSE labe.Putreal(yleft,4);
c.write(labe);
c.moveto(500,110);
labe.Setpos(1); labe.Putreal(xstep/sx,4);
c.write("x-step ="); c.write(labe);

c.moveto(180,150);  labe:="          ";
c.write("y-axis:  x=");  labe.Setpos(1);
IF zerox >=0 THEN labe.Putchar('0') ELSE labe.Putreal(xleft,4);
c.write(labe);
c.moveto(500,150);
labe.Setpos(1); labe.Putreal(ystep/sy,4);
c.write("y-step ="); c.write(labe);

c.scale_y:=sy; c.origin_y:=oy;
c.scale_x:=sx; c.origin_x:=ox;

cosysfor:-c;

END********************************************************
```