% CIRCLE_INTERSECT returns intersection points of two circles in two dimensions % % Format [y]=circle_intersect(P1,P2,r1,r2); % % OUT y coordinates of the intersection points % y(1,:) are closest to origin (x=0,y=0) % if y=nan there is no intersection % % IN P1 coordinates(x,y) of the circle 1 center % P2 coordinates(x,y) of the circle 2 center % r1 radius of circle 1 % r2 radius of circle 2 % % Histiry: created by Bengt Rydberg 2011-11-15 function [y]=circle_intersect(P1,P2,R1,R2); Pv=P1-P2; d=sqrt(Pv*Pv'); if d>(R1+R2) %no solutions (the circles are separate.) y=nan; elseif dd4b y=[P4b;P4a]; else y=[P4a;P4b]; end end