Find cells in array that are crossed by a given line segment
<p>I have got a 2D array of cells with size 10x10, and many points that are  pairs of floating point values, like: (1.6, 1.54), (4.53, 3.23). The pairs (x,y) are such that x&lt;10 and y&lt;10</p>

<p>Each cell takes points whose coordinates have the same integer part as the cell coordinates.
So arr[3][7] will take points with x={3...3.99(9)} and y={7... 7.99(9)}, for example (3.5, 7.1) or (3.2, 7.6). Similarly (1.6, 1.54) is in arr[1][1] , (4.53, 3.23) is in arr[4][3], etc.</p>

<p>Each point has got a designated place in the array that is easy to find, because I just have to cast x and y to int to get rid of the decimal points.</p>

<p>But I would like to find which cells in the array are crossed by the line segment between two points A(x,y) and B(x,y).</p>

<p>For example: A(1.5, 2.5) and B(4.3, 3.2) crosses cells in array with indexes [1][2], [2][2], [3,3] and [3,4]</p>

<p>Is there any algorithm for that?</p>

<p>It is a similar problem to that one:
<a href="https://stackoverflow.com/questions/30707433/cells-in-grid-crossed-by-a-line-php">Cells in grid crossed by a line ( PHP )</a></p>