It seems to me that a simpler way to do this would be: - get the endpoints of the line - figure out the slope of the line - If the slope is <= 1, pull out the x coordinate of the test point. If the slope is > 1, use the y coordinate of the test point - using the algebra that you learned when you were a teenager, figure out what the y (or x) coordinate should be for the value you pulled out in the previous step - see if the point on the line is a reasonable distance away from the corresponding value in the test point.
Dave On Nov 22, 2010, at 8:12 AM, Cody Garvin wrote: > Hi all, > > I searched back through 2005 in the Cocoa Mailing List and didn't see any > requests for this. > > We need all the points on a line / arc / path on the screen. We need to do > hit detection on stroked line, so we must know if the point is valid or not. > > I thought using CGPathContainsPoint would work, but it must be done on a > closed path or it returns true on all points in the test area. > > I also tried NSBezierPath containsPath: and , but it returned the exact same > things as the CGPath functions. > > Another idea I have, though not sure if it will work, is converting the > drawing to NSBitmapImageRep and using colorAtX:y to test for a specific color > to test for a point. > > The downside of this approach is you must test all the points in a bounding > box, and could get quite large if our line segment is complicated. > > I'm surprised I haven't found a convenience method to return all the points > in an outline. > > Any help would be greatly appreciated. > > - Cody_______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com > > This email sent to davedel...@me.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com