Determing Cell I'm in

I have written a small program in which I can walk through a landscape made up of triangles. What I would like to know is how to determine what triangle I am standing in. Your help is much appreciated, thank you very much.

Are the triangle vertices in a regular grid as viewed from above? Or are the vertices irregularly placed?

They are in a grid as viewed from above

Think of the data as a 2d array where each cell contains a pair of triangles. To understand what pair of triangles you’re on, determine what row of triangles you’re in, what column of triangles you’re in and, voila you’ll know what pair of triangles you’re standing on. Say that origo is at the bottom left of the terrain for example, then the column you’re in is :


and the row is:


Now you know which pair of triangles you’re on, so just test against collisions with those.