function [flg,Id] = intersect_pair3(Ra,Rb,Rc,N,p) %Intersection routine O = []; for of = 1:length(N) if p == 2 test = range_intersection(Ra(N(of),:),Rb(N(of),:)); elseif p == 3 test = range_intersection(Ra(N(of),:),range_intersection(Rb(N(of),:),Rc(N(of),:))); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if (length(test) == 4) && all(test(1:2) == [-Inf -Inf]) test = test(3:4); elseif (length(test) == 2) && all(test == [-Inf -Inf]) test = []; end if isempty(test) O = [O 1]; %%no intersection else O = [O 0]; %%Intersection end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % if (length(test) == 4) && all(test(1:2) == [-Inf -Inf]) && any(test ~= -Inf) % O = [O 0]; %%Intersection % % Val = [Val;test]; % elseif (((length(test) == 2) || (length(test) == 4)) && all(test == -Inf)) % O = [O 1]; %%no intersection % % Val = [Val;-Inf -Inf -Inf -Inf]; % elseif isempty(test) % O = [O 1]; %%no Intersection % % Val = [Val;-Inf -Inf -Inf -Inf]; % % elseif ((length(test) == 4) && all(test == -Inf) % % O = [O 1]; %%no Intersection % % Val = [Val;-Inf -Inf -Inf -Inf]; % elseif ((length(test) == 2) && all(test ~= -Inf)) % O = [O 0]; %%Intersection % else % disp('bug detect') % end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % if (length(test) == 4) && all(test(1:2) == [-Inf -Inf]) % % test = test(3:4); % O = [O 0]; %%Intersection % elseif isempty(test) || ((length(test) == 2) && all(test == [-Inf -Inf])) % % test = []; % O = [O 1]; %%no intersection % end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% end if all(O) flg = 1; Id = []; else flg = 0; Id = find(O == 0); end end