Fix bug in barycentric interpolation when gridRes > 1

Triangle for interpolation was being picked incorrectly when gridRes > 1.
Fix this and make the code more readable by converting coordinates inside
the grid cell to range 0-1.