Re: fast intersection calculation between bezier & rectangle
- From: "Ylem.GL@xxxxxxxxx" <Ylem.GL@xxxxxxxxx>
- Date: 19 May 2007 21:13:41 -0700
On May 20, 12:39 am, "Dave Eberly" <dNOSPAMebe...@xxxxxxxxxxxxxxx>
wrote:
<Ylem...@xxxxxxxxx> wrote in message
news:1179564418.999716.61620@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm currently working on a 2D drawing app which allows users to
drag their mouses in the canvas to select from a lot of bezier curves.
To figure out which bezier curves are selected seems a bit difficult
to me.
I tried to sample the bezier into dozens of line segments and
calculate the intersection between the line segments and the selection
rectangle, but it seems not very efficient (especially when the number
of curves grows to 50+)
Can anyone give me some suggestions on how to figure out the
intersect set much more efficiently, please?
Using your approach, preprocess the line segments of the polylines
that approximate the curves. Compute the axis-aligned bounding boxes
of the segments. Sort the projections of these relative to the x-axis.
Now when a user creates a tracking rectangle, you can quickly locate
which segments the rectangle edges potentially intersect by locating
those axis-aligned boxes that the rectangle edges intersect. The idea
is effectively that ofhttp://www.cs.cmu.edu/~baraff/sigcourse/notesd2.pdf.
Also look at the recent thread in this newsgroup; the subject is
"Intersection of bezier and straight line". You can compute the
intersection of rectangle edge and Bézier curve directly by converting
the problem to computing the roots of a polynomial. Finding roots can
also be computationally expensive. As a quick "no intersection", you
can use Sturm sequences for the polynomial and test whether the
polynomial has no real-valued roots, in which case the edge does not
intersect the curve. These tests involve only basic arithmetic operations.
--
Dave Eberlyhttp://www.geometrictools.com
thanks for your help
it helps me greatly :)
PS: Dave, I can't open geometrictools.com in my browser when I was
trying to find some material (many people suggest your web site) on
this topic. (from China)
The firefox says:
"The connection was reset
The connection to the server was reset while the page was loading."
.
- Follow-Ups:
- Re: fast intersection calculation between bezier & rectangle
- From: Dave Eberly
- Re: fast intersection calculation between bezier & rectangle
- References:
- [help] fast intersection calculation between bezier & rectangle
- From: Ylem.GL@xxxxxxxxx
- Re: [help] fast intersection calculation between bezier & rectangle
- From: Dave Eberly
- [help] fast intersection calculation between bezier & rectangle
- Prev by Date: Re: EPA Penetration depth
- Next by Date: Re: fast intersection calculation between bezier & rectangle
- Previous by thread: Re: fast intersection calculation between bezier & rectangle
- Next by thread: Re: fast intersection calculation between bezier & rectangle
- Index(es):
Relevant Pages
|