determine if a given point is inside the polygon

后端 未结 3 2155
挽巷
挽巷 2020-12-13 16:36

Given a convex polygon as a counter-clockwise list of n vertices, give O(lgn) algorithm to determine if a given point is inside the polygon. Assume the basic operations take

3条回答
  •  难免孤独
    2020-12-13 17:07

    The condition for a point to be inside a polygon is that the point should be on same side of all line segments. You should check for the sign of the distance of the point in question with each line segments that make up the polygon - if all are same sign the point is inside the polygon. A google search should give you many algorithms.

提交回复
热议问题