From: Phrogz Date: 2007-02-08T04:35:08+09:00 Subject: Re: Algorithm Help - Grid Space Calculations On Feb 7, 12:25 pm, "Martin DeMello" wrote: > Here you go: [snip] > ppu = pixel_width / world_width > factor = 2 ** lg2(ppu).ceil > low = BASE_GRID_SIZE / factor > high = low * 2 > $grid_spacing = ($grid_spacing-high).abs < ($grid_spacing-low).abs ? high : low [snip] Excellent, thanks! :) The logarithm stuff is exactly what was needed (translating it to a factor in particular). And even though you transcribed into Ruby what I wrote in English with the "nearest to the current setting" constraint, for some reason I couldn't come up with it.