I have created a grid in python. Each cell has its own id (bottom left corner on the image) and its own coordinates (top left corner on the image).
Is it possible to calculate the id of the cell if you have the coordinates of the cell?
I have created a grid in python. Each cell has its own id (bottom left corner on the image) and its own coordinates (top left corner on the image).
Is it possible to calculate the id of the cell if you have the coordinates of the cell?
Let x / y be our co-ordinate pair. The id is given by (x - 1) + 5*(y - 1) = x + 5*y - 6
As a python function we could use the following:
def find_id(x, y):
return x + 5*y - 6