How can I tell if a closed path contains a given point?

前端 未结 5 1232
广开言路
广开言路 2020-11-29 00:19

In Android, I have a Path object which I happen to know defines a closed path, and I need to figure out if a given point is contained within the path. What I was hoping for

5条回答
  •  情书的邮戳
    2020-11-29 00:49

    I know I'm a bit late to the party, but I would solve this problem by thinking about it like determining whether or not a point is in a polygon.

    http://en.wikipedia.org/wiki/Point_in_polygon

    The math computes more slowly when you're looking at Bezier splines instead of line segments, but drawing a ray from the point still works.

提交回复
热议问题