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
[arrayTools] fix sectRect boundary case #3354
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice I've done the same change in my JS port in Fontra, so that makes me +1.
417558c
to
513867a
Compare
use '>' instead of '>=' when comparing intersection of two rectangles, so we don't skip boundary case when the two touch Fixes #3352
513867a
to
dad5bc6
Compare
@simoncozens I noticed that when making this change to sectRect, from no intersections, we now find 4 intersections for the test curves (from dad5bc6) that touch exactly at t=0.5, but they look like duplicates.
I see that
if rectArea(bounds1) < precision and rectArea(bounds2) < precision:
return [(midpoint(range1), midpoint(range2))]
unique_key = lambda ts: (int(ts[0] / precision), int(ts[1] / precision))
seen = set()
unique_values = []
for ts in found:
key = unique_key(ts)
if key in seen:
continue
seen.add(key)
unique_values.append(ts) Maybe we need to use precision*precision (squared) when checking the areas (given area itself is not a single-dimension dinstance but... an area), so that we then obtain more precise intersections whose ts will get rounded off with given precision and will become equal and deduped? |
basically this bfd874a |
This stuff (any kind of cubic-cubic intersection logic) is horribly complicated and full of floating-point imprecision and edge cases and I've basically hit the limit of my knowledge here. (Actually I hit the limit of my knowledge here.) Raph has been working on a new algorithm for Kurbo but I'm not sure what state that's in. |
use '>' instead of '>=' when comparing intersection of two rectangles, so we don't skip boundary case when the two touch
Fixes #3352