0

I have a mesh of cells in memory. I know the width and height of the cells, X0,Y0, X1,Y1, X2,Y2. Given a line connecting (X1,Y1) to (X2,Y2) I would like a way to determine the cells crossed by this line. I have hashed the cells that should get sellected in my drawing. I would like an idea on how to solve this and i will build the implementation in PHP.

Grid with selected cells

Liviu
  • 1,023
  • 2
  • 12
  • 33
  • It's just the equation of a line and then using your known x and y extents calculate the cells in-between at whatever resolution is sufficient for your needs. – mccainz Jun 08 '15 at 11:25
  • More recent, but exactly the same with answers: [Find cells in array that are crossed by a given line segment](https://stackoverflow.com/questions/35807686) – Cimbali Mar 05 '16 at 18:21

0 Answers0