Update grid.c

Fixed computeDirection()