void set_scales ( PSStream *ps, dg_Interval bbox[], double hmin, double hmax, double vmin, double vmax ); /* Adjusts the scales of the Postscript picture stream {ps} so that the client rectangle {bbox[0] × bbox[1]} fits snugly (with equal scales) in the plotting area, which is the rectangle {[hmin _ hmax] × [vmin _ vmax]}, in pt, relative to the lower left corner of the figure. */ void set_scales ( PSStream *ps, dg_Interval bbox[], double hmin, double hmax, double vmin, double vmax ) { /* Fit {bbox} in the given plot window, with equal scales for X and Y. */ double xc = (bbox[0].end[BLO] + bbox[0].end[BHI])/2; double yc = (bbox[1].end[BLO] + bbox[1].end[BHI])/2; double wx = (bbox[0].end[BHI] - bbox[0].end[BLO])/2; double wy = (bbox[1].end[BHI] - bbox[1].end[BLO])/2; double wh = (hmax - hmin)/2; double wv = (vmax - vmin)/2; double scale = 1.02 * (wx/wh > wy/wv ? wx/wh : wy/wv); double xmin = xc - wh*scale, xmax = xc + wh*scale; double ymin = yc - wv*scale, ymax = yc + wv*scale; pswr_set_window ( ps, xmin, xmax, ymin, ymax, hmin, hmax, vmin, vmax, 1,1 ); }