[Date Index] [Thread Index] [Author Index]
RE: Point inside a plygon?
Hi, we can know if a point is inside a polygon using the following calculation... It works for right or left ordered polygons (it changes the sign of I) Denoting by P the point and V_i the set of N vertex of the polygon, we can calculate the following I = Sum( angle(V_(i+1)-P, V_i-P), i=1..N-1) + angle(V_N-P,V_1-P) if I != 0 then P is inside the polygon. If P == 0 the P is outside. with angle returning a value in ]-Pi,Pi] or ]-180,180]. This is a discrete form of a Gauss integral (from complex calculus) I hope this helps.... Rafa Rafael Torres Carot rtorres at onera.fr torres at lmt.ens-cachan.fr Spanish PhD Student en el extranjero