-
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
Curve.isStraight() return false with straight line with straight handle #1269
Comments
It's measuring the absolute handle, meaning |
Ha, you're right! I am assuming absolute positions there, but they are vectors at this point. Great find! : ) |
Fixing this is easy, but it does produce a row of failing tests due to this recent change here: @iconexperience it now finds much more intersections in situations where paths almost overlap, as it falls back onto the line-line more often. I think if we manage to get overlap detection working better, than these should go away... And it actually helps in my situations with my path offsetting experiments, so it does seem to be the right step. What do you think? |
Also include code that prevents Curve.getIntersections() from failing now. Work in progress. Relates to #1269
@iconexperience I've pushed the code now to https://github.com/paperjs/paper.js/tree/is-straight (see bad4d02) I included a hack that prevents the unit tests from failing, see here: bad4d02#diff-6393c249dbbb25dc0e510bd9d91b268dR1771 The local function check = recursion ? hasNoHandles : Curve.isStraight, ...to... check = Curve.isStraight, ...you will see the error in effect in the unit tests. I have introduced an optional 2nd epsilon argument for This should serve as good base for further testing. |
Some more insight:
To test for collinearity as well in } else if (l.getDistance(p1.add(h1)) < e
&& l.getDistance(p2.add(h2)) < e) { ...to... } else if (l.getDistance(p1.add(h1)) < e
&& l.getDistance(p2.add(h2)) < e
&& h1.isCollinear(v) && h2.isCollinear(v)) { |
The remaining issues then all stem from this sketch here by you, @iconexperience: We used to find 4 intersections, now it finds 7... |
I should add that all the remaining failing tests, regardless of the versions described in #1269 (comment), are only occurring with almost overlapping curves. Without the collinearity checks, but with reduced epsilon, I get 31 intersections instead of 4 in one test. This may not be a bad thing actually, it just means we should improve how we handle overlaps probably... What I find interesting is that when I use this version that produces the most intersections, all my remaining issues in my path offsetting experiments go away (situations such as #1263). This doesn't mean it's right, but maybe it is... |
I am still trying to catch up, but just one remark: Checking for handles should never return |
That-s a very interesting observation! The hack I just implemented to preserve previous behavior, since this is basically more or less what the wrong definition of With @naan discovering this issue here, we found out about this mistake with rather good timing. But now we have a whole lot of new question marks : ) @hkrish recently mentioned his approach of handling overlaps to me, I will find out if this is something that may help us prevent these edge cases. But I would also like to roll out |
@iconexperience one remark: we don't have smaller call limits anymore, we're back to the old ones. |
@lehni I notices the call limits change just after posting my comment. And yes, I think the best would be to have a temporary fix. This is quite a big discovery and should be investigated closely. |
I just tried this out, to see if it makes any difference, basically only checking straight curves on the first call of straight1 = abort || !recursion && Curve.isStraight(v1, epsilon),
straight2 = abort || !recursion && Curve.isStraight(v2, epsilon); and this creates a new issue: In the overlap edge case #1239 in the unit tests, one intersection is not found anymore. This used to be found when the fat-line epsilon was This basically means that the case where curves are so small after many subdivisions that it's ok to treat it as a line does indeed solve issues. |
Interesting... If I reduce the maximum for |
@iconexperience look at 8461d8d, with this everything works again, and the correct The only problem I am seeing now is that due to the added collinearity checks which solved the breaking cases, I am back to seeing issues in my offsetting experiments. But that just needs more investigation now, and thanks to this issue here I now have a hint. |
glad I found a good one. Nice work always! |
In this change,
Curve.isStraight
uses handle point rather control point to get distance fromLine(p1, p2)
which I think some case doesn't work.Here's Sketch
The following code getting distance
h1
/h2
seems wrong to me. Shouldn't this to be comparing with control point (point+handleIn/Out) instead of handleIn/Out?I'm testing on
develop
branch.The text was updated successfully, but these errors were encountered: