0

I's looking for simple(easy to implement algorithm) to check whether a point is inside the square/rectangle/polygon(convex)

I use CAShaperLayer to draw the polygon and I know there is hittest method in CAShaperLayer. For some reason, I don't allow to use hittest.

What I did so far:

I use a circle to approximate the polygon and check whether a point is inside the circle(choose three points and generate a circle since three point determine a circle). The approximate method works but it is not accurate.

elliptic00
  • 427
  • 4
  • 13
  • 1
    See http://stackoverflow.com/questions/217578/point-in-polygon-aka-hit-test – rmaddy Sep 10 '15 at 22:29
  • Are all the shapes representable as UIBezierPaths? If yes then use -containsPoint https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBezierPath_class/#//apple_ref/occ/instm/UIBezierPath/containsPoint: – Alistra Sep 10 '15 at 23:14

0 Answers0