This is pldtik.c in view mode; [Download] [Up]
/* If tick == 0, this works out a "nice" interval, so that there */ /* are between 3 and 7.5 major tick intervals in the input range */ /* "vmin" to "vmax". Using this value for the tick interval or */ /* supplied value, it also computes "prec" which specifies */ /* the number of places that should be written after the decimal */ /* point. The recommended number of subticks is returned in */ /* "nsubt" unless the routine is entered with a non-zero value */ /* of "nsubt". The output variable "mode" is set to 0 if */ /* labels are to be written in floating-point format, or to 1 if */ /* they are to be written in scientific format. */ #include "plplot.h" #include <math.h> void pldtik(vmin, vmax, tick, nsubt, mode, prec, scale) double vmin, vmax, *tick; int *nsubt, *mode, *prec, *scale; { double t1, t2, vmod; int np, ns; vmod = MAX(ABS(vmin),ABS(vmax)); *mode = 0; *scale = 0; if (vmod < 1.0e-2 || vmod > 1.0e6) { *mode = 1; t1 = log10(vmod); *scale = (int)floor(t1); } t1 = log10(ABS(vmax-vmin)); np = (int)floor(t1); t1 = t1 - np; if (t1 > 0.7781512503) { t2 = 2.0 ; ns = 4; } else if (t1 > 0.4771212549) { t2 = 1.0 ; ns = 5; } else if (t1 > 0.1760912591) { t2 = 5.0; ns = 5; np = np-1; } else { t2 = 2.0; ns = 4; np = np-1; } if (*tick == 0.0) { *tick = t2 * pow(10.0,(double)np); if (vmin > vmax) *tick = -*tick; } else { t1 = log10(ABS(*tick)); np = (int)floor(t1); } if (*nsubt == 0) *nsubt = ns; if (*mode != 0) *prec = *scale-np+1; else *prec = MAX(-np,0); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.