Q: test algorithm to decide if point is inside area here's a geometric problem that I've been unsuccessful to solve:


*

*we have four points A, B, C, D defining an area

*and two points E, F

*E is within the boundaries of the polygon ABCD

*F is outside the borders


We know the (x, y) coordinates of each point.
(see the figure below)

Determine for any point
G (x, y) if G is inside or outside ABCD
Any ideas out there?
Thanks
Adrien

A: For your specific problem (quadrilateral - convex), you can do the following:
    1) calculate the equations for the 4 sides
    2) calculate the intersection of a vertical line which has G on it with each line
    3) if you find an even number of intersections, then it is outside
    4) if you find an odd number of intersections, then it is inside
    5) be careful at the endpoint intersections
    6) be careful if G is on one of the sides
