Skip to content
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

Fix point disappearing during curve merging #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mental-design
Copy link

@mental-design mental-design commented Feb 5, 2021

Overview

This commit fixes an issue where a point suddenly disappears during merging.
The problem was caused by an off-by-one error in the clipping coordinates.
The problem was fixed by including t = 1 when looking for a t-value during curve fitting in _tValueForPointOnCubicCurve.

Details

Test file: thin.ufo.zip

Here's the outline before merging.
Screen Shot 2021-02-05 at 3 35 32 PM

And the output after merging.
Screen Shot 2021-02-05 at 3 37 19 PM

Looking at the merge point in detail, there was an offset by 1 (an error of 1 / 2 ^ 17).
download

One of the points, the point on 47, was removed by pyclipper so the output contour was smooth.
However this difference caused the curve to go into the condition on line 806 in OutputContour.reCurveSubSegments where it thinks the end of flatSegment is different from inputSegment.flat[0].
In that condition, we search for the tValue for a point 1 (in 2^17) off the end point. The solver from inputSegment.tValueForPoint(searchPoint) returns 1.0 which gets filtered out by line 968:

solutions = [t for t in solutions if 0 <= t < 1]

The result of this is tValues = [] and in turn this skips the condition on line 853 thus a point gets omitted/deleted.

Allowing the t-value solver to include the end point fixes the issue.
Screen Shot 2021-02-05 at 3 54 37 PM

@mental-design mental-design changed the title Fix point disappearing during union on curves Fix point disappearing during merge on curves Feb 5, 2021
@mental-design mental-design changed the title Fix point disappearing during merge on curves Fix point disappearing during curve merging Feb 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants