How to determine the coords for the cell that is on the edge of a grid that intersects a line that extends from a source cell at a given angle?

43 Views Asked by At

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.

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

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.