[grid_map_core] Determine length of line within grid map cell
Why? For occupancy mapping, I want to use a decay rate model, e.g. as presented here. Therefore, I need the distance a ray travelled within each cell.
How? This blog post describes how that length can be computed for axis aligned 2D boxes.
So I started an implementation using the cell position corresponding to the current index and two cached variables, the starting point (corresponding to the start index) and the elementwise inverse of the line direction, respectively.
Implementation I tested my code, it works and it is ok-ish fast. However, I would be happy if you have further suggestions on how to improve performance. For example, one could cache the previous and next indices to reduce the number of operations.