Shafaet's blog

By Shafaet, 9 years ago, In English
Given all the points of a n-sided polygon in anti-clockwise order i need to find if a specific point P lies inside the polygon or not.

I searched in google and found 2 good algorithms. Ray Casting algorithm and Winding Number algorithm. I think the second one is simpler and less likely to result in floating point error.

I am not very good at geometry and i am facing difficulty in finding the angles in Winding algo. Wikipedia says "If the winding number is non-zero, the point lies inside the polygon. One way to compute the winding number is to sum up the angles subtended by each side of the polygon." So if the angle is exactly zero, than the point is outside.

Can anyone help me to measure the angles? I am not sure when an angle should be negative.

Thanks in advance :).

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it