summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-06-20 16:51:43 +0200
committerGitHub <noreply@github.com>2024-06-20 16:51:43 +0200
commitc030e3283530bc1d0f4bad219f4c61db22750506 (patch)
tree5d24181c34b087658bbf6b7174bdd58c9c074ad3
parentdb915fe214bbfdc0b9f71b96cf752fc072db82cc (diff)
Fix short relative lock stitches (#2998)
-rw-r--r--lib/stitch_plan/lock_stitch.py25
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/stitch_plan/lock_stitch.py b/lib/stitch_plan/lock_stitch.py
index e05764de..1a8923af 100644
--- a/lib/stitch_plan/lock_stitch.py
+++ b/lib/stitch_plan/lock_stitch.py
@@ -85,25 +85,20 @@ class RelativeLock(LockStitchDefinition):
to_previous = stitches[1] - stitches[0]
length = to_previous.length()
- lock_stitches = []
- if length > 0.5 * PIXELS_PER_MM:
+ # travel at least 0.5 and at most 1.5
+ length = max(length, 0.5 * PIXELS_PER_MM)
+ length = min(length, 1.5 * PIXELS_PER_MM)
- # Travel back one stitch, stopping halfway there.
- # Then go forward one stitch, stopping halfway between
- # again.
+ direction = to_previous.unit()
- # but travel at most 1.5 mm
- length = min(length, 1.5 * PIXELS_PER_MM)
+ # Travel back one stitch, stopping halfway there.
+ # Then go forward one stitch, stopping halfway between
+ # again.
- direction = to_previous.unit()
+ lock_stitches = []
+ for delta in path:
+ lock_stitches.append(Stitch(stitches[0] + delta * length * direction, tags=('lock_stitch',)))
- for delta in path:
- lock_stitches.append(Stitch(stitches[0] + delta * length * direction, tags=('lock_stitch',)))
- else:
- # Too short to travel part of the way to the previous stitch; just go
- # back and forth to it a couple times.
- for i in (1, 0, 1, 0):
- lock_stitches.append(stitches[i])
return lock_stitches