• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Obtaining all points on a line segment
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Obtaining all points on a line segment


  • Subject: Re: Obtaining all points on a line segment
  • From: Dave DeLong <email@hidden>
  • Date: Mon, 22 Nov 2010 20:16:30 -0800

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 (email@hidden)
>
> 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:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >Core data fetch and multithreading (From: vincent habchi <email@hidden>)
 >Re: Core data fetch and multithreading (From: Quincey Morris <email@hidden>)
 >Re: Core data fetch and multithreading (From: vincent habchi <email@hidden>)
 >Re: Core data fetch and multithreading (From: Quincey Morris <email@hidden>)
 >Re: Core data fetch and multithreading (From: Hunter Hillegas <email@hidden>)
 >Obtaining all points on a line segment (From: Cody Garvin <email@hidden>)

  • Prev by Date: Re: Help diagnosing networking/internet performance issues
  • Next by Date: Re: NSExpression is incorrect?
  • Previous by thread: Obtaining all points on a line segment
  • Next by thread: Re: Obtaining all points on a line segment
  • Index(es):
    • Date
    • Thread