-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Shape union produces wrong results if points of overlapping shapes touch on horizontal lines. #450
Comments
At the moment, we have no way to handle overlapping paths I am afraid. That is the reason for the paths merely touching each other as well. This is the main limitation of Boolean ops in paperjs right now. I briefly looked at some research the skia guys did, they seem to be handling it separately from normal intersections. I have to look into this problem in detail. Again. Sorry for the delay. I am quite busy at job right now, and will be, probably until Easter. @lehni I will keep you posted. /hari
|
You mean situations, where the curves cover each other and don't result in one intersection, but theoretically in an infinite amount of solutions, right? Because if we can't handle any overlapping paths, then what would the point of boolean ops be? :) I'm guessing that with the infinite solutions, we would need a way to pick one as a valid intersection location. Wouldn't we have to choose between the start and end points of both curves, simply? |
Yes, I meant when two bezier curves overlap at least a portion of their span. The part after that looks a bit hard though. i.e. when we traverse the graph later. The reason, is that, we have to conditionally process the overlapping regions according to the operator and the location of the next and previous curves. For a quick example, consider the Union operator, two paths below are overlapping by some amount, Now here are two other paths, overlapping about the same region, This is only for one operator. And for others several of these edge cases exist. This is why for now I just opted for the easy solution. To be exact, overlapping (osculating is the technical term) curves are a degenerate case for boolean ops. However, I agree with you guys that we absolutely need this. I am just trying to explain that, this is not a bug, but a limitation at the moment. I will look into this once we have the offset paths sorted out. /Hari |
@hkrish isn't it strange though that the rotated paths produce the correct result? Isn't this perhaps simply an issue of horizontal paths not handled correctly? |
I did look at it in detail. The issue is with overlapping paths. The transformation may nudge the points just enough that the paths may not be precisely on top of one another anymore. Try changing the It might seem arbitrary, but a subtle difference in the slope of these curves determine which path is being taken, when we sort and choose a path to traverse at an intersection. What we need is a conscious design choice of how the algorithm should behave. Also might need some code to identify the parts that are overlapping. This may not be the only issue when we deal with overlapping paths. So may be it is a good idea to keep this issue open for now? |
Yes that makes a lot of sense. Do you think this is something we can address in the current implementation, as opposed to the new approach that you once mentioned? |
Who would have thought! I managed to address these issues in the current code base, and the work in the |
I'm sorry @hkrish to report more bugs with the boolean code! Check this example, derived from #449:
Resulting in:
Now if you uncomment that
rotate(15)
command, you get:Note that there are still extra points that we could get rid off, but that I guess is fine?
http://sketch.paperjs.org/#S/lZAxT8MwEIX/yslLiojcBBSGoE5dGRCMTQeTXKnBvYvcS6tS9b9zCUqkToAn+31Pfu/ubMjt0JTm9ROl3prU1Nz074OL0DrZ5rAAwiM8692+YC2O3gPOzhWBnpY9SQmrhyyFIlunP+ref6GKxZW48SEsOXAsIYnYJKMXg36KTQkSO6zocvNYUUVj/N2f4vPsf/lvocNfCszn0Eb+UGRdLf6AT+6E0UYWJzjLi+ua91pz2JbtyCsfqveWAdopW23JCUPgYzLBsYCyvsGkt7z34pngdgErHUWHXCs0l28=
The text was updated successfully, but these errors were encountered: