Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-03 - decus/20-0078/libsim/scales.sim
There is 1 other file named scales.sim in the archive. Click here to see a list.
OPTIONS(/E);
! Procedure SCALESTEP calculates variables
! suitable for axis design.
! PMAX is input max (rough) value and at return justified max value.
! PMIN ditto min.
! PTICS is number of increments along axis (Result parm.)
! SCALESTEP is size of axis increment.
;
REAL PROCEDURE scalestep(pmax,pmin,ptics);
NAME pmax,pmin,ptics;   REAL pmax,pmin;   INTEGER ptics;
BEGIN
    REAL max,min,width,d;
    INTEGER n0,n1,pow;

    max:= pmax;   min:= pmin;

    width:= Abs(max - min);
    IF width NE 0 THEN
    BEGIN

	WHILE width > 10 DO
	BEGIN    width:= width*0.1;   pow:= pow + 1   END;
	WHILE width <= 1 DO
	BEGIN   width:= width*10;   pow:= pow - 1   END;


	! Normalize width ;
	IF width NE Entier(width) THEN
	width:=
	IF width > 8    THEN 10 ELSE
	IF width > 1.5  THEN Entier(width+1) ELSE
	IF width > 1.25 THEN 1.5 ELSE 1.25;

	! Calculate normalized increment ;
	d:=
	IF width >= 8.0 THEN 2 ELSE
	IF width > 3.5  THEN 1 ELSE
	IF width > 1.6  THEN 0.5 ELSE 0.25;

	! Now scale normalized increment d ;
	WHILE pow > 0 DO
	BEGIN   d:= d*10;    pow:= pow - 1   END;
	WHILE pow < 0 DO
	BEGIN   d:= d*0.1;   pow:= pow + 1   END;

	! Calculate number of increments ;
	n1:= Entier(max/d);    IF n1*d < max THEN n1:= n1 + 1;
	n0:= Entier(min/d);

	ptics:= n1 - n0;

	pmax:= n1*d;   pmin:= n0*d;

	scalestep:= d;

    END width NE 0;

END of scalestep;