 abs    = Math.abs
 acos   = Math.acos
 cos    = Math.cos
+floor  = Math.floor
 max    = Math.max
 min    = Math.min
 random = Math.random

        id = t.id
        continue if id == tid || seen[id]
        tp = others[id]
        continue unless tp and gd[tp] <= distance
        sin3 = gd[ tp + 1 ]
        seg3 = gd[ tp + 3 ]
        keep = if seg3 == seg1 or seg3 == seg2

    for other in c.neighbors when other[1] <= @maxRadius()
      f(t) for t in other[0].inhabitants
    i[0] for i in ar.sort (a,b) -> a[1] - b[1]
  cellAt: ( x, y ) ->
    x = 0 unless x >= 0
    y = 0 unless y >= 0
    w = @cellWidth
    column = @cells[ div x, w ]
    return @cellAt( x - 1, y ) unless column
    cell = column[ div y, w ]
    return @cellAt( x, y - 1 ) unless cell
    cell
  # place a thing in the appropriate cell
  place: (thing, onlyMovingIn) ->
    cell = @cellAt thing.x, thing.y
