Dear all, I'd like to know if there is a common approach to this problem:

I have a line segment defined by points

**a** and

**b** over a 2D plane. That plane is divided in Squares of the same size. I need to find a list of all the squares which the "

**ab**" segment passes through.

I know:

- Points
**a** and **b **coordinates - The size and position of the Squares
- The Line Equation for
**ab** (the Slope and the Y-Intercept)

I know I can pick any

**X** value and calculate its

**Y** intercept on the

**ab** segment, and there for say if that point is inside a square or not, but this aproach may involve iterating and unwanted CPU computing (given I want to implement this concept into a computer graphics experiment).

Thanks in advance for any tip!!