Is the mesh just a grid of squares?
If it is and the triangles are all in sequential order you could just use some arbitrary math to decide which triangle shares this triangles hypot.
If it is and the triangles are all in sequential order you could just use some arbitrary math to decide which triangle shares this triangles hypot.