GRASS Programmer's Manual
6.4.1(2011)
|
00001 /* 00002 **************************************************************************** 00003 * 00004 * MODULE: Vector library 00005 * 00006 * AUTHOR(S): Original author CERL, probably Dave Gerdes. 00007 * Update to GRASS 5.7 Radim Blazek. 00008 * 00009 * PURPOSE: Lower level functions for reading/writing/manipulating vectors. 00010 * 00011 * COPYRIGHT: (C) 2001 by the GRASS Development Team 00012 * 00013 * This program is free software under the GNU General Public 00014 * License (>=v2). Read the file COPYING that comes with GRASS 00015 * for details. 00016 * 00017 *****************************************************************************/ 00018 #include <grass/gis.h> 00019 #include <grass/Vect.h> 00020 00021 double 00022 dig_x_intersect(double beg_x, 00023 double end_x, double beg_y, double end_y, double Y) 00024 { 00025 double b, a; 00026 00027 b = (end_x - beg_x) / (end_y - beg_y); 00028 a = beg_x - b * beg_y; 00029 return (a + b * Y); 00030 } 00031 00032 int dig_in_area_bbox(P_AREA * Area, double x, double y) 00033 { 00034 #ifdef GDEBUG 00035 G_debug(3, "BBOX: (x,y) (%lf, %lf)\n", x, y); 00036 G_debug(3, "NSEW: %lf, %lf, %lf, %lf\n", Area->N, Area->S, Area->E, 00037 Area->W); 00038 #endif 00039 if (x < Area->W) 00040 return (0); 00041 if (x > Area->E) 00042 return (0); 00043 if (y < Area->S) 00044 return (0); 00045 if (y > Area->N) 00046 return (0); 00047 00048 return (1); 00049 }