• 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: Does cocoa just leak?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does cocoa just leak?


  • Subject: Re: Does cocoa just leak?
  • From: John Hörnkvist <email@hidden>
  • Date: Mon, 1 Oct 2001 02:40:45 +0200

On Sunday, September 30, 2001, at 10:07 PM, j o a r wrote:

On Sunday, September 30, 2001, at 08:34 , John Hvrnkvist wrote:

It's quite possible that NSBezierPath calls "bezierPathByFlatteningPath" in that code and solves each generated line segment for the point. Flattening will eat lots of memory for complex paths.

This is what ObjectAlloc tells me about one of the allocations. It does seem like it uses "bezierPathByFlatteningPath" - it seemed to me like a class method to return a new path - that 's why I said it copied the path. Perhaps it isn't so?

It flattens the path, and that means replacing any curve segment by a lot of short lines.

You are absolutely right about it requiring a lot of resources though John - is there an alternative way to obtain the x position on a path given a known y-position? It takes way to long time as it is now. I was never very good at math in school, mind you... ;)

Here is the fundamental formula:
<http://www.bergen.org/AAST/Projects/3DSMaxTutorial/bezier_formula.gif>
and this picture illustrates the meaning:
<http://www.bergen.org/AAST/Projects/3DSMaxTutorial/bezier_diagram1.gif>

You can iterate over the function until you find a point that matches yours, or you can try to solve the equation for each line segment. You should be able to make Newton-Raphson solve it, or you could solve the cubic equation. Solving cubics is a bit messy; pick up a good math reference book. (I like "Beta, Mathematics Handbook" by Lennart Rede and Bertil Westergren. For those that happen to be in Sweden, it should be available from your nearest university bookstore, eg Cremona at Chalmers.)

Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com


  • Prev by Date: Re: [Carbon] Using Speech in Cocoa
  • Next by Date: Bezier path math (was: Does cocoa just leak?)
  • Previous by thread: Re: [Carbon] Using Speech in Cocoa
  • Next by thread: Re: Does cocoa just leak?
  • Index(es):
    • Date
    • Thread