-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intersecting a patch
with a path3
can be extremely slow
#6
Comments
CI: Run apt-get update before installing.
A thought I had on this problem this morning: Ideally, you would test whether the convex hulls of the control points intersect; using the bounding boxes instead of the control points is a quick-and-dirty way to get a valid result, but it can also give rise to lots of false positives that make for many unnecessary iterations. The "rotation" suggestion is meant to reduce these false positives, but it's not particularly elegant. But consider this: To tell whether two convex hulls intersect, you don't actually have to compute the convex hulls -- you only have to determine whether the two sets of points are linearly separable. And that can be done using linear programming. This should provide a fairly straightforward solution that is both more powerful and more appealing than the "rotation trick" suggestion. |
Here's one simple example:
Intersecting a line with a plane should not take 46 seconds, even if the line is nearly parallel to the plane. Here's a somewhat more complex example:
The resulting output:
In other words, this intersection took over 32 seconds to compute.
Possible strategy for fixing: in the final
intersections
function inpath3.cc
, before computing bounding boxes, apply a rotation (to both the path and the patch) so that three of the patches four corners lie in a plane parallel to the xy-plane. When the patch subdivision gets small enough, the patches will be nearly planar, and applying the suggested rotation can drastically reduce the volume of the bounding box (and hopefully also the extraneous path segments it catches).Another suggestion, specifically targeted at the second example, is to keep halving the path3 until both halves intersect the bounding box of the patch. (Then put those two halves back together?) The idea is to make sure that extremely long path segments get cut down to size in the very first step; I don't know how well it would really work.
The text was updated successfully, but these errors were encountered: