diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2023-06-27 01:45:08 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-27 07:45:08 +0200 |
| commit | d836245e1f4e5fbd2213c18588641b7bfec58ccb (patch) | |
| tree | 12cf4bcae889af6900eea3c0c051d08bdfe026ac | |
| parent | 52ba1afb7532514adee18939f37c51805642f235 (diff) | |
avoid divide by zero (#2382)
| -rw-r--r-- | lib/elements/satin_column.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/elements/satin_column.py b/lib/elements/satin_column.py index e48973ac..86c6d05a 100644 --- a/lib/elements/satin_column.py +++ b/lib/elements/satin_column.py @@ -909,7 +909,7 @@ class SatinColumn(EmbroideryElement): # Base the number of stitches in each section on the _longer_ of # the two sections. Otherwise, things could get too sparse when one # side is significantly longer (e.g. when going around a corner). - num_points = max(path0.length, path1.length) / spacing + num_points = max(path0.length, path1.length, 0.01) / spacing # Section stitch spacing and the cursor are expressed as a fraction # of the total length of the path, because we use normalized=True @@ -967,7 +967,7 @@ class SatinColumn(EmbroideryElement): # more than 5%. if iterations <= 2: distance = self._stitch_distance(pos0, pos1, old_pos0, old_pos1) - if abs((current_spacing - distance) / current_spacing) > 0.05: + if distance > 0.01 and abs((current_spacing - distance) / current_spacing) > 0.05: # We'll revise to_travel then go back to the start of # the loop and try again. to_travel = (current_spacing / distance) * to_travel @@ -1296,6 +1296,6 @@ class SatinProcessor: if self.use_random: roll = prng.uniform_floats(self.seed, self.cycle) self.cycle += 1 - return 1.0 + ((roll[0] - 0.5) * 2) * self.random_zigzag_spacing + return max(1.0 + ((roll[0] - 0.5) * 2) * self.random_zigzag_spacing, 0.01) else: return 1.0 |
