Re: Re: Tracking rectangles and bezier paths
Re: Re: Tracking rectangles and bezier paths
- Subject: Re: Re: Tracking rectangles and bezier paths
- From: Wagner Truppel <email@hidden>
- Date: Fri, 8 Sep 2006 16:39:28 -0700
It's not as hard a math problem as suggested, even if the curve is
not monotonic. Recall that the entire bezier path is contained within
the convex hull of the path's control points so a very simple
solution is to retrieve the control points, compute their convex hull
(which is a convex polygon, in 2 dimensions), and use that as your
tracking area. Computing convex hulls in 2 dimensions is almost
trivial - any decent book on algorithms will tell you how.
Wagner
============
You cannot simultaneously prevent and prepare for war.
- Albert Einstein
Thanks, That is about what I suspected. I suppose that if the curve
is monotonic then it is straightforward to do the math in case 2.
On Sep 8, 2006, at 9:44 AM, Raphael Sebbe wrote:
Hi,
That involves computing an intersection between a region around the
mouse cursor and the curve.
1. If you draw that curve yourself in OpenGL (I mean tesselate it as
segments), this is pretty straightforward, as you set up a pickbuffer
and render the scene a second time only in that region arond the
mouse
and see if the curve is inside or not by parsing the pick buffer.
2. If your are using NSBezierPath, well, it seems more difficult to
me, at least it involves parsing the control points and doing about
the same thing as 1 or other fancy math yourself.
Of course, there are workarounds, like landmining the path or just
doing that effect when the mouse enters control point handles.
HTH,
Raphael
On 9/8/06, Dave Budde <email@hidden> wrote:
I've seen at least one application (Space Designer in Logic Pro
comes
to mind) that can track a bezier curve and highlight it when a mouse
enters and exits the proximity of the curve. Is there a similar
thing to tracking rectangle that can do this or does one need to
create a bunch of little rects along the path and assign them the
same proximity variable.
Dave
_______________________________________________
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