Skip to content

Commit

Permalink
fix: GridIterator iteration order
Browse files Browse the repository at this point in the history
  • Loading branch information
bogovicj committed Jan 9, 2025
1 parent b6a5b4f commit 55682ee
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/main/java/org/janelia/saalfeldlab/n5/util/GridIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,32 @@ public int getIndex() {
return index;
}

final static public void indexToPosition(long index, final long[] dimensions, final long[] min, final long[] position) {
final int maxDim = dimensions.length - 1;
for (int dim = maxDim; dim >= 0; dim--) {
position[dim] = index % dimensions[dim] + min[dim];
final static public void indexToPosition(long index, final long[] dimensions, final long[] offset,
final long[] position) {
for (int dim = 0; dim < dimensions.length; dim++) {
position[dim] = (index % dimensions[dim]) + offset[dim];
index /= dimensions[dim];
}
}

final static public void indexToPosition(long index, final long[] dimensions, final long[] position) {
for (int dim = 0; dim < dimensions.length; dim++) {
position[dim] = index % dimensions[dim];
index /= dimensions[dim];
}
}

final static public void indexToPosition(long index, final int[] dimensions, final long[] offset,
final long[] position) {
for (int dim = 0; dim < dimensions.length; dim++) {
position[dim] = (index % dimensions[dim]) + offset[dim];
index /= dimensions[dim];
}
}

final static public void indexToPosition(long index, final int[] dimensions, final long[] position) {
for (int dim = 0; dim < dimensions.length; dim++) {
position[dim] = index % dimensions[dim];
index /= dimensions[dim];
}
}
Expand Down

0 comments on commit 55682ee

Please sign in to comment.