/* Coordinate transformations for plotting package */

#include "plplot.h"
#include "declare.h"
#include <math.h>

/* dcmm. converts from device coordinates to millimetres from bottom */
/* left-hand corner */

float dcmmx(x)
float x;
{
      return((float)(x * abs(phyxma-phyxmi) / xpmm));
}

float dcmmy(y)
float y;
{
      return((float)(y * abs(phyyma-phyymi) / ypmm));
}

/* dcsc. define transformations between device coordinates and subpage */
/* coordinates */

float dcscx(x)
float x;
{
      return((float)((x - spdxmi)/(spdxma-spdxmi)));
}

float dcscy(y)
float y;
{
      return((float)((y - spdymi)/(spdyma-spdymi)));
}

/* mmdc. converts millimetres from bottom left corner into device */
/* coordinates */

float mmdcx(x)
float x;
{
      return((float)(x * xpmm / abs(phyxma - phyxmi)));
}

float mmdcy(y)
float y;
{
      return((float)(y * ypmm / abs(phyyma - phyymi)));
}

/* scdc. converts subpage coordinates to device coordinates */

float scdcx(x)
float x;
{
      return((float)(spdxmi + (spdxma-spdxmi) * x));
}

float scdcy(y)
float y;
{
      return((float)(spdymi + (spdyma-spdymi) * y));
}

/* wcmm. converts world coordinates into millimetres */

float wcmmx(x)
float x;
{
      return((float)(wmxoff + wmxscl*x));
}

float wcmmy(y)
float y;
{
      return((float)(wmyoff + wmyscl*y));
}

float w3wcx(x,y,z)
float x, y, z;
{
      return((float)((x-basecx)*cxx + (y-basecy)*cxy));
}

float w3wcy(x,y,z)
float x, y, z;
{
      return((float)((x-basecx)*cyx+(y-basecy)*cyy+(z-ranmi)*cyz));
}


