function [ distance ] = IRSensorRightAll( rectangles,...
    numberOfRectangles, sensorx, sensory, sensorTheta)
%UNTITLED3 Summary of this function goes here
%   Detailed explanation goes here
    distance = -1;
    intersectionx = 0;
    intersectiony = 0;
    
    for i = 1:numberOfRectangles
        rect = rectangles(i, :);
        [thisDistance, thisIntx, thisInty] = IRSensorRight(rect, sensorx, sensory, sensorTheta); 
        if (distance == -1 || (thisDistance > 0 && thisDistance < distance))
            distance = thisDistance;
            intersectionx = thisIntx;
            intersectiony = thisInty;
        end
    end
end

