home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / graphics-0.17 / graph / max.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-11  |  892 b   |  61 lines

  1. #include "sys-defines.h"
  2. #include "extern.h"
  3. #ifndef MAXFLOAT
  4. #define MAXFLOAT 1e29
  5. #endif
  6.  
  7. void
  8. array_min (p, length, min_x, min_y)
  9.      point_struct *p;
  10.      int length;
  11.      double *min_x;
  12.      double *min_y;
  13. {
  14.   int i;
  15.  
  16.   if (length == 0)
  17.     {
  18.       *min_x = 0.;
  19.       *min_y = 0.;
  20.       return;
  21.     }
  22.   *min_x = MAXFLOAT;
  23.   *min_y = MAXFLOAT;
  24.     
  25.   for (i=0; i<length; i++)
  26.     {
  27.       if (p[i].x < *min_x)
  28.     *min_x = p[i].x;
  29.       if (p[i].y < *min_y)
  30.     *min_y = p[i].y;
  31.     }
  32. }
  33.  
  34.  
  35. void
  36. array_max (p, length, max_x, max_y)
  37.      point_struct *p;
  38.      int length;
  39.      double *max_x;
  40.      double *max_y;
  41. {
  42.   int i;
  43.  
  44.   if (length == 0)
  45.     {
  46.       *max_x = 0.;
  47.       *max_y = 0.;
  48.       return;
  49.     }
  50.   *max_x = -1. * MAXFLOAT;
  51.   *max_y = -1. * MAXFLOAT;
  52.     
  53.   for (i=0; i<length; i++)
  54.     {
  55.       if (p[i].x > *max_x)
  56.     *max_x = p[i].x;
  57.       if (p[i].y > *max_y)
  58.     *max_y = p[i].y;
  59.     }
  60. }
  61.