I have a grid whose each cell is determined by its x and y coordinates (integers). This grid is 100x100 wide.
I am given a cell (x0, y0), and an angle A.
My goal is to be able to get the coordinates of all the cells crossed by the line ((x0, y0), A), within the grid.
How can I do that ?? The problem is that I don't have the length of the line...
I was thinking of finding a second point and then use Bresenham's algorithm, but it's too long to compute it because the second point I find is usually outside my grid. Thus I was thinking of modifying Bresenham's algorithm (http://www.roguebasin.com/index.php?title=Bresenham%27s_Line_Algorithm#Python), but I don't have a clue how to do it given that the algorithm is based on the fact that we have two points on the input ! :/
Thank you in advance for your help.
Assume that the angle is such that the line will exit the grid along the x-axis before exiting along the y-axis. This means you know the x co-ordinate of the end of that line, and can compute its y co-ordinate using the formula given by @AxelKemper. (If need be, swap the roles of x & y in the above.) If you can't tell which is the case beforehand, just pick one, do the computation, and if it falls outside the grid, use the other case.