function cells = rok_room_cells_at_location (room, x, y)
    % cells = ROK_ROOM_CELLS_AT_LOCATION (room, x, y)
    %
    % Find cells that cover the specified location
    %
    % Input:
    %  - room = room configuration structure, obtained by ROK_ROOM_CREATE()
    %  - x = x coordinate
    %  - y = y coordinate
    %
    % Output:
    %  - cells = array of indices of cells that cover specified location
    %
    % See also: ROK_ROOM_CELL_TO_XY, ROK_ROOM_CREATE
    %
    % Copyright (C) 2011-2012, Rok Mandeljc <rok.mandeljc@fe.uni-lj.si>
    
    [ X, Y ] = ndgrid(room.xVals, room.yVals);
    
    L = X(:)' - room.cell_size(1)/2;
    R = X(:)' + room.cell_size(1)/2;
    T = Y(:)' - room.cell_size(2)/2;
    B = Y(:)' + room.cell_size(2)/2;

    % Floating point comparison sucks... :(
    x = x + eps;
    y = y + eps;
    
    cells = find( x >= L & x <= R & y >= T & y <= B );
end