inside.c 1.2 KB

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