is_point_in_polygon - Determines if a point is inside a polygon


#include "g/g_geometry.h"

Example compile flags (system dependent):
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 

int is_point_in_polygon
	const Matrix *points_mp,
	const Vector *test_point_vp


This routine determines if a point, assumed to be co-planer with a convex polygon, is inside that polygon. The polygon is specified by a list of points in cyclic order placed in the rows of the matrix point_mp. The points can be of any dimension, but this routine assumes that they lie in a 2-D subspace. The boundary of the polygon is considered part of the polygon, so if the point is on the boundary, then the routine returns TRUE.


TRUE if the point is inside the polygon, FALSE if not, and ERROR if there are any problems, with an error message being set.


If the points are out of order, or if the polygon is not convex, or if the point is not in the plane of the polygon, then this routine will not work!


Qhull output: The edges of facets of a 3D hull are not in cyclic order. One solution is do call this routine for each triangle. Also, the edges of a 2D hull are not in order, unless find_convex_hull() was called with the ORDER_2D_HULL_FACETS option.


The algorithm used in this routine is not very good. Should be fixed sometime.


This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.


Kobus Barnard


Kobus Barnard


get_polygon_CM_and_area , get_ordered_polygon_CM_and_area , is_point_in_segment , order_planer_points