gridmap 0.0.2

library for handling infinite multi-dimensional grids of cells
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Translate indexes

use super::Transform;

/// Translate the index
pub struct Translate<const D: usize>(pub [isize; D]);

/// Apply the transformation to the given index
impl<const D: usize> Transform<D> for Translate<D> {
    fn apply(&self, index: &mut [isize; D]) {
        // flip the indexes
        for (d, i) in index.iter_mut().enumerate() {
            *i += self.0[d];
        }
    }
}