inside.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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/vector.h>
  19. double
  20. dig_x_intersect(double beg_x,
  21. double end_x, double beg_y, double end_y, double Y)
  22. {
  23. double b, a;
  24. b = (end_x - beg_x) / (end_y - beg_y);
  25. a = beg_x - b * beg_y;
  26. return (a + b * Y);
  27. }
  28. int dig_in_area_bbox(struct P_area * Area, double x, double y)
  29. {
  30. #ifdef GDEBUG
  31. G_debug(3, "BBOX: (x,y) (%lf, %lf)\n", x, y);
  32. G_debug(3, "NSEW: %lf, %lf, %lf, %lf\n", Area->N, Area->S, Area->E,
  33. Area->W);
  34. #endif
  35. if (x < Area->W)
  36. return (0);
  37. if (x > Area->E)
  38. return (0);
  39. if (y < Area->S)
  40. return (0);
  41. if (y > Area->N)
  42. return (0);
  43. return (1);
  44. }