How to determine which cells in a grid intersect with a given triangle?

Posted by Ray Dey on Game Development See other posts from Game Development or by Ray Dey
Published on 2011-01-24T20:05:57Z Indexed on 2011/01/28 23:39 UTC
Read the original article Hit count: 234

I'm currently writing a 2D AI simulation, but I'm not completely certain how to check whether the position of an agent is within the field of view of another.

Currently, my world partitioning is simple cell-space partitioning (a grid). I want to use a triangle to represent the field of view, but how can I calculate the cells that intersect with the triangle?

Similar to this picture: enter image description here

The red areas are the cells I want to calculate, by checking whether the triangle intersects those cells.

Thanks in advance.

EDIT:

Just to add to the confusion (or perhaps even make it easier). Each cell has a min and max vector where the min is the bottom left corner and the max is the top right corner.

© Game Development or respective owner

Related posts about collision-detection

Related posts about intersection