Re: collision nsbezierpath
Re: collision nsbezierpath
- Subject: Re: collision nsbezierpath
- From: Robert Clair <email@hidden>
- Date: Tue, 24 Jan 2006 22:27:40 -0500
I have to NSBezierPath object in a view.
How can I determine if the second path is inside the first.
Check the archives and Google. Particularly:
http://www.faqs.org/faqs/graphics/algorithms-faq/
1) You must either know a priori or determine that the two paths
don't intersect. Otherwise the 2nd is neither inside nor outside the
other. Determining this means checking every segment of path one
against every segment of path 2 for intersections. Doing this for
curved segments is a pain. If you can use a tessellated approximation:
NSBezierPath* myPath;
NSBezierPath* tessellatedPath;
tessellatedPath = [myPath bezierPathByFlatteningPath];
it is merely tedious.
2) Once you have answered (1) you can pick a candidate test point on
path 2 and see if that point is inside the other path. Then you can do
BOOL is2Inside1 = [myPath1 containsPoint: pointOnMyPath2];
To see how this is actually carried out look at:
http://www.acm.org/tog/editors/erich/ptinpoly/
....Bob Clair
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden