Re: Determing the intersection of two NSBezierPath(s)
Re: Determing the intersection of two NSBezierPath(s)
- Subject: Re: Determing the intersection of two NSBezierPath(s)
- From: Arnaud Forgiel <email@hidden>
- Date: Wed, 13 Nov 2002 01:33:33 -0800 (PST)
On Tuesday, Nov 12, 2002, at 08:50PM, Jeremy Faller <email@hidden> wrote:
>
All:
>
>
Let's pretend I have two NSBezierPaths, and I would like to determine if they intersect (or even better, what the intersection of the two paths would be -- returned as a BezierPath)? I imagine with some clever NSBezierPath work this could be done, but I haven't seen the path forward.
>
>
Thanks in advance.
>
>
>
Regards,
>
Jeremy
Jeremy,
Your question cannot be answered so easily. This is a complex subject with different results depending on your assumptions. You should consider the following cases:
1. Intersection of two 4-control points bezier paths:
This one is an easy case and you should find the answer on the web. The result can be either a point or nothing. My favorite (and easiest) way to find the solution is through recursive analysis of the bounding rectangles, using the de Casteljau subdivision approach.
2. Intersection of two areas delimited by bezier paths (ex: rectangle & oval):
This one is much more complex and requires some understanding of the topology you're dealing with. The result can be of three types: point, path, area (delimited by a path). The main issue with this case is that it's not easy to define a subportion of a bezier curve (i.e. parameter range different from the [0..1] case). Nevertheless, any CAD package is able to do it, and with some time, you should be able to solve it. One hint: look at boolean operations and DCEL (double connected edge link) in the litterature. The key is the data structure you'll use to solve the problem.
3. Complex cases based on 2 but with hole(s):
It is just an extended case of the previous one. Once again, the data structure is the key.
4. Intersection of "dirty" areas (i.e. self-intersecting bounding path):
Once you've cleaned the bounding path by cutting the self-intersecting portion of the path, it's just case 3.
I hope it helps.
Regards,
Arnaud
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.