Swap rotation while swapping placement #97
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.
Here is the current
mutate
function:SVGnest/svgnest.js
Lines 872 to 894 in 1248dc2
When
clone.placement[i]
andclone.placement[i]
are swapped to create an order mutation, I think maybe it is better to also swap theclone.rotation
.For example, if there are two 2 parts called
A
andB
. To put A in the bin,A
can not be rotated by90
degree whileB
can do this.This means, the value of
clone.rotation[j]
(B
) can be90
while the value ofclone.rotation[i]
(A
) is0
.In this case, if
clone.placement[i]
andclone.placement[j]
are swapped, andclone.rotation[i]
orclone.rotation[j]
happens not to be regenerated bythis.randomAngle(clone.placement[i])
later, then it would produce an unexpected mutation result.Although this issue will not happen to small parts data input, I think this change make it more reasonable for big parts input.
Here is the SVG input example mutationExample.zip, if needed, it can be used for test.