Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi! Using the VP3 Writer to export stitch coordinates as embroidery files, I noticed that the stitch coordinates in the written file were not always at the nearest 0.1mm grid point. This was especially noticable with satin patterns, where the stitches got back and forth. in the even runs the stitches were placed differrently than in the odd runs:
Original stitch coordinates (no rounding):

Rounded to the nearest grid point:

Written with VP3 Writer and read back with VP3 Reader:

Coordinates to reproduce it:
stitch_coordinates.py
The reason for this is that the VP3 writer truncates the delta between stitches instead of rounding it. Non-integer stitch coordinates might not be written to their nearest integer grid point. The error depends on which way the needle is moving, so zigzag and satin stitches come out visibly distorted.
There are two causes in Vp3Writer.py:
Minimal example to reproduce it:
Output:
expected (round): [[0, 0], [11, 1], [-11, 1], [11, 2], [-11, 2]]
read back : [[0, 0], [10, 0], [-10, 1], [10, 1], [-10, 2]]
Proposed fix
Round absolute position of each stitch to the nearest integer and compute the delta from the previous rounded position. That way every point lands on its nearest grid point no matter where the previous stitch was. Rounding errors can't build up. The block start position is rounded the same way, so the writer and the reader start from the same point.