ABRG-Models / morphologica

A library of supporting code for numerical modelling (JSON config, HDF5 data, Modern OpenGL visualization)
https://abrg-models.github.io/morphologica/
Apache License 2.0
260 stars 30 forks source link

shift_index functions added into Grid class #278

Closed blenk13 closed 2 weeks ago

blenk13 commented 2 weeks ago

I've written three functions into Grid.

  1. A function that takes an index and horizontal step size (in terms of a number of pixels) as arguments, and outputs the COLUMN index of the new location after the step has been taken.
  2. A function that takes an index and vertical step size (in terms of a number of pixels) as arguments, and outputs the ROW index of the new location after the step has been taken.
  3. A function that takes a start index and a 2D step (as a morph::vec<int, 2>, in terms of numbers of pixels) as arguments and outputs the index after the move has been made.

The functions work with all GridOrders and all GridWraps. Comprehensive unit tests are included and are passing.

I wondered whether it would be best if only (3) were a public function and have (1) and (2) as private ones? But I'll leave that up to you.

sebjameswml commented 2 weeks ago

Right, sorted. I'll wait for the CI to finish and merge it after that