function InsideOrOutside = IsParticleInsideFigure(x,y, FigureBoundaries)
    % Checks whether particle is inside or outside the specified figure
    % boundaries.
    % Output - 
    %    InsideOrOutside - logical (1 => inside the figure, 0 => outside)
    %
    % Input - 
    %    FigureBoundaries - xyStartFigure, xyHoney etc. = xyStartFigure for Start Boundaries
    
    k = zeros(size(FigureBoundaries,1), size(x,1));
    for i = 1:length(FigureBoundaries)
        if length(FigureBoundaries{i}) >= 5 % polygon
            xvStart = FigureBoundaries{i}(:,1);
            yvStart = FigureBoundaries{i}(:,2);
            k(i,:) = inpolygon(x,y,xvStart,yvStart);
        elseif length(FigureBoundaries{i}) == 4 % rectangle
            p = FigureBoundaries{i};
            xvStart = [ p(1) p(1) p(1)+p(3) p(1)+p(3) ];
            yvStart = [ p(2) p(2)+p(4) p(2)+p(4) p(2) ];
            k(i,:) = inpolygon(x,y,xvStart,yvStart);
        else % circle
            k(i,:) = (x-FigureBoundaries{i}(1)).^2 + (y-FigureBoundaries{i}(2)).^2 ...
                <= FigureBoundaries{i}(3).^2;
        end
    end
    if size(k,1) == 1 %Only one figure boundary
        InsideOrOutside = k;
    else % Many viscous regions eg viscous granules
        InsideOrOutside = any(k);
    end
end
