~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to prim/plot/libsrc/boxwtp.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* @(#)boxwtp.c 19.1 (ES0-DMD) 02/25/03 14:07:37 */
 
2
/*===========================================================================
 
3
  Copyright (C) 1995 European Southern Observatory (ESO)
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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, 
 
18
  MA 02139, USA.
 
19
 
 
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 
 
26
                        GERMANY
 
27
===========================================================================*/
 
28
 
 
29
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
30
.COPYRIGHT   (c) 1993 European Southern Observatory
 
31
.IDENTifer   boxwtp.c
 
32
.AUTHOR      R.M. van Hees IPG-ESO Garching
 
33
.KEYWORDS    low level plot routine, pixel convertion
 
34
.LANGUAGE    C
 
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
 
41
.COMMENTS    none
 
42
.ENVIRONment MIDAS
 
43
             #include <midas_def.h>      Prototypes for MIDAS interfaces
 
44
 
 
45
.VERSION     1.0     14-Jun-1993   FORTRAN --> ANSI-C   RvH
 
46
 
 
47
 010423         last modif
 
48
 
 
49
------------------------------------------------------------*/
 
50
/*
 
51
 * Define _POSIX_SOURCE to indicate
 
52
 * that this is a POSIX program
 
53
 */
 
54
#define  _POSIX_SOURCE 1
 
55
 
 
56
/*
 
57
 * definition of the used functions in this module
 
58
 */
 
59
#include <stdlib.h>
 
60
#include <string.h>
 
61
#include <math.h>
 
62
 
 
63
#include <midas_def.h>
 
64
 
 
65
/*
 
66
 * here start the code of the function
 
67
 */
 
68
void BOXWTP( wcax, npix, start, step, pxax )
 
69
int    npix; 
 
70
float  *pxax, *wcax;
 
71
double start, step;
 
72
{
 
73
register int  xy;
 
74
 
 
75
char *string;
 
76
 
 
77
float wcax_xy;
 
78
int  err2small = 0, 
 
79
     err2large = 0;
 
80
 
 
81
static char *str_err   = "*** WARNING: Both coordinates ",
 
82
            *str_small = "fall below frame boundaries",
 
83
            *str_large = "fall beyond frame boundaries";
 
84
 
 
85
 
 
86
for ( xy = 0; xy < 2 ; xy++ )
 
87
    {
 
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) );
 
92
    else
 
93
       wcax_xy = *(wcax+xy);
 
94
 
 
95
    *(pxax+xy) = (float) ceil((wcax_xy - start)/ step )+ 1;
 
96
 
 
97
      if ( *(pxax+xy) <= 0 )
 
98
         { *(pxax+xy) = 1;
 
99
           err2small += 1;
 
100
         }
 
101
 
 
102
      if ( *(pxax+xy) > npix )
 
103
         { *(pxax+xy) = npix;
 
104
           err2large += 1;
 
105
         }
 
106
    }
 
107
 
 
108
if ( err2small > 1 || err2large > 1 )
 
109
   { string = osmmget(70);
 
110
     (void) strcpy( string, str_err );
 
111
     if ( err2small > 1 ) 
 
112
        SCTPUT( strcat( string, str_small ) );
 
113
     else 
 
114
        SCTPUT( strcat( string, str_large ) );
 
115
     (void) osmmfree( string );
 
116
   }
 
117
}