inside.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. ****************************************************************************
  3. *
  4. * MODULE: Vector library
  5. *
  6. * AUTHOR(S): Original author CERL, probably Dave Gerdes.
  7. * Update to GRASS 5.7 Radim Blazek.
  8. *
  9. * PURPOSE: Lower level functions for reading/writing/manipulating vectors.
  10. *
  11. * COPYRIGHT: (C) 2001 by the GRASS Development Team
  12. *
  13. * This program is free software under the GNU General Public
  14. * License (>=v2). Read the file COPYING that comes with GRASS
  15. * for details.
  16. *
  17. *****************************************************************************/
  18. #include <grass/gis.h>
  19. #include <grass/Vect.h>
  20. double
  21. dig_x_intersect(double beg_x,
  22. double end_x, double beg_y, double end_y, double Y)
  23. {
  24. double b, a;
  25. b = (end_x - beg_x) / (end_y - beg_y);
  26. a = beg_x - b * beg_y;
  27. return (a + b * Y);
  28. }
  29. int dig_in_area_bbox(P_AREA * Area, double x, double y)
  30. {
  31. #ifdef GDEBUG
  32. G_debug(3, "BBOX: (x,y) (%lf, %lf)\n", x, y);
  33. G_debug(3, "NSEW: %lf, %lf, %lf, %lf\n", Area->N, Area->S, Area->E,
  34. Area->W);
  35. #endif
  36. if (x < Area->W)
  37. return (0);
  38. if (x > Area->E)
  39. return (0);
  40. if (y < Area->S)
  41. return (0);
  42. if (y > Area->N)
  43. return (0);
  44. return (1);
  45. }