home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / lemming / part01 / lemgeo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-08-05  |  682 b   |  41 lines

  1. /*
  2.  * lemgeo.c - low-level geometric routines
  3.  *
  4.  * copyright (c) by Alan W. Paeth, 1987. All rights reserved.
  5.  */
  6.  
  7. #include "lem.h"
  8.  
  9. ptinrect(px, py, xl, yl, xh, yh, tol)
  10.     {
  11.     xl -= tol;
  12.     yl -= tol;
  13.     xh += tol;
  14.     yh += tol;
  15.     return((xl<=px) && (xh>=px) && (yl<=py) && (yh>=py));
  16.     }
  17.  
  18. hypot(x, y)
  19.     {
  20.     x = ABS(x);
  21.     y = ABS(y);
  22.     if (x>y) return(x+y/2);
  23.     return(y+x/2);
  24.     }
  25.  
  26. dist(x0, y0, x1, y1)
  27.     {
  28.     return(hypot(x1-x0, y1-y0));
  29.     }
  30.  
  31. spacealign(x, y)
  32.     int *x, *y;
  33.     {
  34.     int dx, dy;
  35.     dx = ABS(*x-markx);
  36.     dy = ABS(*y-marky);
  37.     if (dx > FLATTOL * dy) *y = marky;
  38.     if (dy > FLATTOL * dx) *x = markx;
  39.     tickalign(x, y);
  40.     }
  41.