renamed posToIndex to xyToIndex
Added blockposToIndex function.