Plot cross tangent of two circle

3 views (last 30 days)
Debanjan Maity
Debanjan Maity on 28 Aug 2020
Edited: Bruno Luong on 29 Aug 2020
I have center coordinate of two circles and radius of two circles. How to draw this figure joining the cross tangent points?
  2 Comments
Adam Danz
Adam Danz on 28 Aug 2020
I don't have a solution off the top of my head but wouldn't there be 4 possible tangent lines that are tangential to both circles?
John D'Errico
John D'Errico on 28 Aug 2020
Edited: John D'Errico on 28 Aug 2020
Yes. As long as a circle does not contain the other. If one circle is wholly inside the other, then there are no mutually tangent lines. There may also be a problem if the two circles intersect, in which case it would appear there will usually be exactly two tangent lines. If one circle is entirely inside the other, but there is one point of intersection, then you will have exactly one tangent line. And of course, if the two circles have the same center AND the same radius, then there are infinitely many multual tangent lines.
So the number of mutual tangent lines can be any of 0,1, 2, 4, inf.

Sign in to comment.

Answers (1)

Bruno Luong
Bruno Luong on 28 Aug 2020
Edited: Bruno Luong on 29 Aug 2020
% Generate two random circles
boxsize = 10;
% center circle 1
x1 = boxsize*rand;
y1 = boxsize*rand;
% center circle 2
x2 = boxsize*rand;
y2 = boxsize*rand;
% their radius
r1 = 1+rand;
r2 = 1+rand;
% Compute cross tangent s-t
xy1 = [x1; y1];
xy2 = [x2; y2];
v = xy2-xy1;
d = norm(v);
rs = r1+r2;
if rs >= d
error('not possible try to generate again');
end
v = v/d;
s = 1; % sign of s allows to select which of two cross tangents
Q = [v, sign(s)*[-v(2); v(1)]];
c = rs/d;
Qx = Q*[c; sqrt(1-c^2)];
s = xy1 + Qx*r1;
t = xy2 - Qx*r2;
% need to plot circle
phi = linspace(0,2*pi,361);
cs = cos(phi);
ss = sin(phi);
plotcirclefun = @(xy,r) plot(xy(1)+r*cs, xy(2)+r*ss, 'k', 'linewidth', 3);
% Graphical output
figure(1)
clf
hold on
plotcirclefun(xy1, r1);
plotcirclefun(xy2, r2);
plot([s(1) t(1)], [s(2) t(2)], 'k', 'linewidth', 3);
axis equal

Categories

Find more on Language Fundamentals in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!