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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions Lib/booleanOperations/flatten.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,18 +953,23 @@ class OutputPoint(InputPoint):

def _tValueForPointOnCubicCurve(point, cubicCurve, isHorizontal=0):
"""
Finds a t value on a curve from a point.
The points must be originaly be a point on the curve.
This will only back trace the t value, needed to split the curve in parts
Finds a t-value on a curve from a point.
The point must be originally be on the curve.
This will only backtrace the t value, needed to split the curve in parts
"""
pt1, pt2, pt3, pt4 = cubicCurve
a, b, c, d = bezierTools.calcCubicParameters(pt1, pt2, pt3, pt4)
solutions = bezierTools.solveCubic(a[isHorizontal], b[isHorizontal], c[isHorizontal],
d[isHorizontal] - point[isHorizontal])
solutions = [t for t in solutions if 0 <= t < 1]
solutions = bezierTools.solveCubic(
a[isHorizontal],
b[isHorizontal],
c[isHorizontal],
d[isHorizontal] - point[isHorizontal]
)
solutions = [t for t in solutions if 0 <= t <= 1]
if not solutions and not isHorizontal:
# can happen that a horizontal line doens intersect, try the vertical
return _tValueForPointOnCubicCurve(point, (pt1, pt2, pt3, pt4), isHorizontal=1)
# If the horizontal line doesn't intersect, try the vertical
return _tValueForPointOnCubicCurve(point, (pt1, pt2, pt3, pt4),
isHorizontal=1)
if len(solutions) > 1:
intersectionLenghts = {}
for t in solutions:
Expand Down