c# - Determine if (x,y,z) point is inside a shape defined by an array of points -


if have array of points (x,y,z) , given single point (x,y,z), code use determine if point resides within shape defined array?

i drawing blank on one...

i'm using c#

edit

thanks responses guys, comments have found link (http://alienryderflex.com/polygon/) explains process quite well.

thanks!

fyi:

bool pointinpolygon() {        int      i, j=polysides-1 ;       boolean  oddnodes=no      ;        (i=0; i<polysides; i++) {         if (polyy[i]<y && polyy[j]>=y         ||  polyy[j]<y && polyy[i]>=y) {           if (polyx[i]+(y-polyy[i])/(polyy[j]-polyy[i])*(polyx[j]-polyx[i])<x) {             oddnodes=!oddnodes; }}         j=i; }        return oddnodes; } 

it'll need work, thats guts of it.

thanks again

use point know outside shape, , check if line point given point passes through surfaces of shape. if passes through odd number of surfaces, given point inside shape.


Comments

Popular posts from this blog

Delphi Wmi Query on a Remote Machine -