function mask = rok_room_is_inside (room, x, y)
    % mask = ROK_ROOM_IS_INSIDE (room, x, y)
    %
    % Check if given coordinates are inside the room.
    %
    % Input:
    %  - room = room configuration structure, obtained by ROK_ROOM_CREATE()
    %  - x = 1xN array of x coordinates (or 2xN array of x and y
    %    coordinates, if y array is not provided)
    %  - y = 1xN array of y coordinates
    %
    % Output:
    %  - mask = 1xN array of logical values denoting whether corresponding
    %    coordinates are located inside the room or not
    %
    % See also: ROK_ROOM_CREATE
    %
    % Copyright (C) 2011-2012, Rok Mandeljc <rok.mandeljc@fe.uni-lj.si>
    
    if nargin < 3,
        y = x(2, :);
        x = x(1, :);
    end

    % Find the coordinates that are inside the room
    mask = x >= room.area(1) & x <= room.area(3) & y >= room.area(2) & y <= room.area(4);
end
