• 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: How to get the stroke geometry of a NSBezierPath?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get the stroke geometry of a NSBezierPath?


  • Subject: Re: How to get the stroke geometry of a NSBezierPath?
  • From: Mark Onyschuk <email@hidden>
  • Date: Mon, 5 Feb 2007 18:50:16 -0500

(copied, minus graphic, plus a few more words, for benefit of the list)

On 4-Feb-07, at 5:56 PM, Jesse Grosjean wrote:

I'm trying to find the point where a given line intersects a NSBezierPath, and I'd like to also include the paths current stroke in this calculation. I know how to do it without taking the stroke into consideration by using [NSBezierPath-OAExtensions intersectionWithLine:lineStart:lineEnd:] from the Omni frameworks, but that method ignores the paths current stroke.

I think the easiest way to solve this is to find a way to turn the path's stroke into a path itself, and then just use the same test on that path. (if there's a better way please let me know) And so that lead to my question, how can I get and access the stroke geometry from a NSBezierPath.

You might try a geometric approach to solving the problem:

1. find the calculated intersection as you describe above.

2. calculate a normal for the line at that point. I'm not sure whether Omni's library provides normal calculation along a bezier, but it's pretty straightforward and can be gleaned using the same technique as is used to calculate an intercept: progressively split the bezier into "flatter and flatter" line segment approximations, then locate the intercept by doing a straight-line intercept calculation with the appropriate split segment.

3. given the line width (actually, given 1/2 the line width, since a stroke is applied equidistantly to either side of the conceptual line), step back to the edge from the standard intersection point. To do this: conceptualize a right triangle whose hypotenuse is your own line pointing in towards the calculated intersection point. The adjacent side is the normal from the calculated intercept and has a length of 1/2 line width. SOHCAHTOA (man, that brings back memories of HS math) gives us: cos theta = adjacent / hypotenuse.

so your hypotenuse length is (1/2 line width) / (cos theta)

-Mark

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: How to get the stroke geometry of a NSBezierPath?
      • From: Jesse Grosjean <email@hidden>
References: 
 >How to get the stroke geometry of a NSBezierPath? (From: Jesse Grosjean <email@hidden>)

  • Prev by Date: Re: MSSQL
  • Next by Date: Re: Hove to retrieve 'living' objects [CoreData / Bindings]
  • Previous by thread: How to get the stroke geometry of a NSBezierPath?
  • Next by thread: Re: How to get the stroke geometry of a NSBezierPath?
  • Index(es):
    • Date
    • Thread