How to determine which cells in a grid intersect with a given triangle?
- by Ray Dey
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:
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.