Tweaked the code a bit to bring it up-to-date with latest versions of Xcode and iOS.
Made the maximum angle and minimum distance to center configurable.