From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/gio/wcstogki.x | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 sys/gio/wcstogki.x (limited to 'sys/gio/wcstogki.x') diff --git a/sys/gio/wcstogki.x b/sys/gio/wcstogki.x new file mode 100644 index 00000000..e0591402 --- /dev/null +++ b/sys/gio/wcstogki.x @@ -0,0 +1,61 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include + +# GPL_WCSTOGKI -- Transform world coordinates to GKI coordinates using the +# cached transformation parameters. There are three possible types of scaling +# on either axis, linear, log, and "elog". The latter is a piecewise log +# scaling function defined for all X, i.e., for negative as well as positive +# X (see elogr.x). If a negative number is transformed with normal log +# scaling it is treated as an indefinite, i.e., plotted as a gap in the plot. + +procedure gpl_wcstogki (gp, wx, wy, mx, my) + +pointer gp # graphics device descriptor +real wx, wy # world coordinates of point +real mx, my # metacode coordinates of point + +real x, y +real elogr() +include "gpl.com" + +begin + # Update cached transformation parameters if device changes, cache + # has been invalidated, or the current WCS has been changed. + + if (gp != gp_out || GP_WCS(gp) != wcs) + call gpl_cache (gp) + + # Transform the coordinates. + + if (xtran == LINEAR) { + x = wx + } else if (xtran == LOG) { + if (wx <= 0) { + call gpl_flush() + return + } else + x = log10 (wx) + } else + x = elogr (wx) + + if (ytran == LINEAR) { + y = wy + } else if (ytran == LOG) { + if (wy <= 0) { + call gpl_flush() + return + } else + y = log10 (wy) + } else + y = elogr (wy) + + # Return real rather than int GKI coordinates to avoid digitization + # errors in a sequence of draws relative to the current pen position. + + mx = max (0.0, min (real(GKI_MAXNDC), + ((x - wxorigin) * xscale) + mxorigin)) + my = max (0.0, min (real(GKI_MAXNDC), + ((y - wyorigin) * yscale) + myorigin)) +end -- cgit