RADICALAXIS Compute the radical axis (or radical line) of 2 circles. L = radicalAxis(C1, C2) Computes the radical axis of 2 circles. Example C1 = [10 10 5]; C2 = [60 50 30]; L = radicalAxis(C1, C2); hold on; axis equal;axis([0 100 0 100]); drawCircle(C1);drawCircle(C2);drawLine(L); See also lines2d, circles2d, createCircle Ref: http://mathworld.wolfram.com/RadicalLine.html http://en.wikipedia.org/wiki/Radical_axis ------ Author: David Legland e-mail: david.legland@grignon.inra.fr Created: 2007-05-15, using Matlab 7.4.0.287 (R2007a) Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas.
0001 function line = radicalAxis(circle1, circle2) 0002 %RADICALAXIS Compute the radical axis (or radical line) of 2 circles. 0003 % 0004 % L = radicalAxis(C1, C2) 0005 % Computes the radical axis of 2 circles. 0006 % 0007 % Example 0008 % C1 = [10 10 5]; 0009 % C2 = [60 50 30]; 0010 % L = radicalAxis(C1, C2); 0011 % hold on; axis equal;axis([0 100 0 100]); 0012 % drawCircle(C1);drawCircle(C2);drawLine(L); 0013 % 0014 % See also 0015 % lines2d, circles2d, createCircle 0016 % 0017 % Ref: 0018 % http://mathworld.wolfram.com/RadicalLine.html 0019 % http://en.wikipedia.org/wiki/Radical_axis 0020 % 0021 % ------ 0022 % Author: David Legland 0023 % e-mail: david.legland@grignon.inra.fr 0024 % Created: 2007-05-15, using Matlab 7.4.0.287 (R2007a) 0025 % Copyright 2007 INRA - BIA PV Nantes - MIAJ Jouy-en-Josas. 0026 % 0027 0028 % extract circles parameters 0029 x1 = circle1(:,1); 0030 x2 = circle2(:,1); 0031 y1 = circle1(:,2); 0032 y2 = circle2(:,2); 0033 r1 = circle1(:,3); 0034 r2 = circle2(:,3); 0035 0036 % distance between each couple of centers 0037 dist = sqrt((x2-x1).^2 + (y2-y1).^2); 0038 0039 % relative position of intersection point of 0040 % the radical line with the line joining circle centers 0041 d = (dist.^2 + r1.^2 - r2.^2) * .5 ./ dist; 0042 0043 % compute angle of radical axis 0044 angle = lineAngle(createLine([x1 y1], [x2 y2])); 0045 cot = cos(angle); 0046 sit = sin(angle); 0047 0048 % parameters of the line 0049 x0 = x1 + d*cot; 0050 y0 = y1 + d*sit; 0051 dx = -sit; 0052 dy = cot; 0053 0054 % concatenate into one structure 0055 line = [x0 y0 dx dy];