Exemple #1
0
def gridify(a, grid_num, offset):
    interval = map_size / grid_num
    b = Point(0,0)
    b.x = int((a.x + offset.x) / interval)
    b.y = int((a.y + offset.y) / interval)
    if b.x == grid_num:
        b.x = grid_num - 1 # Edge case
    if b.y == grid_num:
        b.y = grid_num - 1 # Edge case
    return b
Exemple #2
0
def degridify(a, offset, grid_num):
    interval = map_size / grid_num
    b = Point(0,0)
    b.x = a.x * interval + (interval / 2.0) - offset.x
    b.y = a.y * interval + (interval / 2.0) - offset.y
    return b