home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 6
/
FreshFish_September1994.bin
/
bbs
/
misc
/
cp-4.3.lha
/
cP
/
Source
/
func.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-12
|
1KB
|
68 lines
#include "cp.h"
LONG ScaleX( double val )
{
return( LOGX ? logX( val ) : linX( val ) );
}
LONG ScaleY( double val )
{
return( LOGY ? logY( val ) : linY( val ) );
}
double ZoomX( WORD val )
{
return( LOGX ? logZoomX( val ) : linZoomX( val ) );
}
double ZoomY( WORD val )
{
return( LOGY ? logZoomY( val ) : linZoomY( val ) );
}
__inline LONG linX( double val )
{
return (LONG) ((double)( val - cv.xmin ) / cv.xdelta * WIDTH + xoff);
}
__inline LONG linY( double val )
{
return (LONG) (-(double)( val - cv.ymin ) / cv.ydelta * HEIGHT + yoff);
}
double linZoomX( WORD val )
{
return (( val - xoff ) / (double)WIDTH * cv.xdelta + cv.xmin);
}
double linZoomY( WORD val )
{
return (-( val - yoff ) / (double)HEIGHT * cv.ydelta + cv.ymin);
}
__inline LONG logX( double val )
{
return (LONG) ( ( log10( val ) - log10( cv.xmin )) / ( log10( cv.xmax ) - log10( cv.xmin )) * WIDTH + xoff );
}
__inline LONG logY( double val )
{
return (LONG) ( -( log10( val ) - log10( cv.ymin )) / ( log10( cv.ymax ) - log10( cv.ymin )) * HEIGHT + yoff );
}
double logZoomX( WORD val )
{
return ( pow( 10.0, log10( cv.xmin) + ((double)( val - xoff ) / WIDTH) * (log10( cv.xmax) - log10( cv.xmin))));
}
double logZoomY( WORD val )
{
return ( pow( 10.0, log10( cv.ymin) + ((double)( yoff - val ) / HEIGHT) * (log10( cv.ymax) - log10( cv.ymin))));
}
void Round( double *g )
{
UBYTE s[32];
sprintf( s,"%18.9lf",*g);
sscanf( s,"%le",g);
}