how to test points inside/outside the polygon(homework)

i have a list a test point(x,y coordinate), and i store them into array(testpt[i][0]& testpt[i][1])

how can i test those points are inside the polygon or not?
But i understand the code since i am a beginner.
Can someone wrote the code for me to do the homework?
My classmates use interception to count the number of interception between the line of polygon and test points.
odd number is inside and even number is outside.
Last edited on
> My classmates use interception to count the number of interception between the line of polygon
> and test points. odd number is inside and even number is outside.

Yes. The simple ray casting algorithm.
http://en.wikipedia.org/wiki/Point_in_polygon#Ray_casting_algorithm

Why can't you just use that?

i try to write the code but there are some special cases like passing though vertexs and same point on 2 different lines(pass through twice)
The result is not corrected
> i try to write the code but there are some special cases

Let us have a look at the code (without the special cases). Once we know what you have done so far, we can try and take it forward.
Topic archived. No new replies allowed.