How can I determine whether a 2D Point is within a Polygon?

前端 未结 30 2165
醉梦人生
醉梦人生 2020-11-21 05:06

I\'m trying to create a fast 2D point inside polygon algorithm, for use in hit-testing (e.g. Polygon.contains(p:Point)). Suggestions for effective tech

30条回答
  •  醉梦人生
    2020-11-21 05:58

    For Detecting hit on Polygon we need to test two things:

    1. If Point is inside polygon area. (can be accomplished by Ray-Casting Algorithm)
    2. If Point is on the polygon border(can be accomplished by same algorithm which is used for point detection on polyline(line)).

提交回复
热议问题