1
/* @(#)boxwtp.c 19.1 (ES0-DMD) 02/25/03 14:07:37 */
2
/*===========================================================================
3
Copyright (C) 1995 European Southern Observatory (ESO)
5
This program is free software; you can redistribute it and/or
6
modify it under the terms of the GNU General Public License as
7
published by the Free Software Foundation; either version 2 of
8
the License, or (at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public
16
License along with this program; if not, write to the Free
17
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
20
Correspondence concerning ESO-MIDAS should be addressed as follows:
21
Internet e-mail: midas@eso.org
22
Postal address: European Southern Observatory
23
Data Management Division
24
Karl-Schwarzschild-Strasse 2
25
D 85748 Garching bei Muenchen
27
===========================================================================*/
29
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30
.COPYRIGHT (c) 1993 European Southern Observatory
32
.AUTHOR R.M. van Hees IPG-ESO Garching
33
.KEYWORDS low level plot routine, pixel convertion
35
.PURPOSE compute pixel coordinates and check for legal boundaries
36
input: float *wcax image pixel in world coordinates
37
int npix # of pixels in the x direction
38
double start start of image in x in world unit
39
double step distance between x pixels in world unit
40
output: int *pxax image coordinatex in pixel coordinates
43
#include <midas_def.h> Prototypes for MIDAS interfaces
45
.VERSION 1.0 14-Jun-1993 FORTRAN --> ANSI-C RvH
49
------------------------------------------------------------*/
51
* Define _POSIX_SOURCE to indicate
52
* that this is a POSIX program
54
#define _POSIX_SOURCE 1
57
* definition of the used functions in this module
63
#include <midas_def.h>
66
* here start the code of the function
68
void BOXWTP( wcax, npix, start, step, pxax )
81
static char *str_err = "*** WARNING: Both coordinates ",
82
*str_small = "fall below frame boundaries",
83
*str_large = "fall beyond frame boundaries";
86
for ( xy = 0; xy < 2 ; xy++ )
88
if ( *(wcax+3) <= -2.0 ) /*natural logarithmic scale*/
89
wcax_xy = (float) exp( *(wcax+xy) );
90
else if ( *(wcax+3) < 0.0 ) /*logarithmic scale*/
91
wcax_xy = (float) pow( 10.0, *(wcax+xy) );
95
*(pxax+xy) = (float) ceil((wcax_xy - start)/ step )+ 1;
97
if ( *(pxax+xy) <= 0 )
102
if ( *(pxax+xy) > npix )
108
if ( err2small > 1 || err2large > 1 )
109
{ string = osmmget(70);
110
(void) strcpy( string, str_err );
112
SCTPUT( strcat( string, str_small ) );
114
SCTPUT( strcat( string, str_large ) );
115
(void) osmmfree( string );