diff --git a/Lib/booleanOperations/flatten.py b/Lib/booleanOperations/flatten.py index 8f1d7e1..942bed6 100644 --- a/Lib/booleanOperations/flatten.py +++ b/Lib/booleanOperations/flatten.py @@ -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: