How do you determine the coordinates for the cell that is on the furthest edge of a grid that intersects an imaginary line that extends from a source cell at a given angle. The grid has a finite size of x number of rows and columns. The image below shows illustrates the problem with two example angles on a grid that is 12 rows X 8 columns. The green colored cell is the source cell. The red colored cells are the edge cells that I am trying to determine the cell coordinates.

Answering my own question after some thought. It's basic linear algebra. First, find the equation of the source cell line. Then solve where the line intersects the X axis or Y axis of the grid edge.