summaryrefslogtreecommitdiff
path: root/lib/stitch_plan/lock_stitch.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stitch_plan/lock_stitch.py')
-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