Faster coordinate convertation to array index