function index=index(position,n_grid,axis)
%OK
%returns index in direction of selected axes of point at selected position
index=mod(-floor(-position/n_grid^(axis-1)),n_grid);
if index==0
    index=n_grid;
end
end