GRASS Programmer's Manual  6.4.2(2012)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
inside.c
Go to the documentation of this file.
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 
21 double
22 dig_x_intersect(double beg_x,
23  double end_x, double beg_y, double end_y, double Y)
24 {
25  double b, a;
26 
27  b = (end_x - beg_x) / (end_y - beg_y);
28  a = beg_x - b * beg_y;
29  return (a + b * Y);
30 }
31 
32 int dig_in_area_bbox(P_AREA * Area, double x, double y)
33 {
34 #ifdef GDEBUG
35  G_debug(3, "BBOX: (x,y) (%lf, %lf)\n", x, y);
36  G_debug(3, "NSEW: %lf, %lf, %lf, %lf\n", Area->N, Area->S, Area->E,
37  Area->W);
38 #endif
39  if (x < Area->W)
40  return (0);
41  if (x > Area->E)
42  return (0);
43  if (y < Area->S)
44  return (0);
45  if (y > Area->N)
46  return (0);
47 
48  return (1);
49 }