필터 지우기
필터 지우기

Calculating coordinates for Inner / transverse common tangent points

조회 수: 3 (최근 30일)
Hello all,
I've been trying to calculate this for sometime and have not had much luck. I am trying to calculate the coordinates for the four points in which two inner common tangent lines intersect with two circles. It is assumed that the two circles at coordinates C1 = [x1 y1] and C2 = [x2 y2] circles are of equal radii.
I have found something similar
However, this calculates the coordinates for the outer common tangent points. I have found plenty of resources regarding the lengths of the tangent lines but I am trying to determine the exact coordinates along the circle in which they intersect/touch.
Similar to this image:
Any assistance would be greatly appreciated,
Thank you!

채택된 답변

John D'Errico
John D'Errico 2015년 1월 15일
편집: John D'Errico 2015년 1월 15일
Sooooo many ways to do this. Here are two.
#1. Just basic algebra. You have two circles.
(x-x1)^2 + (y-y1)^2 = r^2
(x-x2)^2 + (y-y2)^2 = r^2
You are looking for the pair of lines that cross, so are tangent to opposite sides of the circle.
Where is the intersection of those lines? An easy conclusion, since the circles have the same radii, is that the intersection point MUST lie at the mid-point between the two circle centers. Thus:
x0 = (x1 + x2)/2
y0 = (y1 + y2)/2
The lines MUST EACH pass through that point, (x0,y0). Those lines can then be written as
y - y0 = s*(x-x0)
y - y0 = t*(x-x0)
where s and t are the respective slopes of the pair of lines.
Now, just find the intersection of one of those lines with the circles. Do so by substituting for y in the circle equation:
subs((x-x1)^2 + (y-y1)^2 - r^2,y,y0+s*(x-x0))
ans =
(x - x1)^2 + (y1/2 - y2/2 + s*(x1/2 - x + x2/2))^2 - r^2
Solve for x, such that we have an intersection. Of course, we get two solutions.
solve((x - x1)^2 + (y1/2 - y2/2 + s*(x1/2 - x + x2/2))^2 - r^2,x)
ans =
(2*x1 + s*y1 - s*y2 + s^2*x1 + s^2*x2 + (4*r^2*s^2 + 4*r^2 - s^2*x1^2 + 2*s^2*x1*x2 - s^2*x2^2 + 2*s*x1*y1 - 2*s*x1*y2 - 2*s*x2*y1 + 2*s*x2*y2 - y1^2 + 2*y1*y2 - y2^2)^(½))/(2*(s^2 + 1))
(2*x1 + s*y1 - s*y2 + s^2*x1 + s^2*x2 - (4*r^2*s^2 + 4*r^2 - s^2*x1^2 + 2*s^2*x1*x2 - s^2*x2^2 + 2*s*x1*y1 - 2*s*x1*y2 - 2*s*x2*y1 + 2*s*x2*y2 - y1^2 + 2*y1*y2 - y2^2)^(½))/(2*(s^2 + 1))
But that was a quadratic polyomial, and we know that we wish a single solution for the intersection. So solve for the slope that yields a discriminant of zero in that solution.
s = solve(4*r^2*s^2 + 4*r^2 - s^2*x1^2 + 2*s^2*x1*x2 - s^2*x2^2 + 2*s*x1*y1 - 2*s*x1*y2 - 2*s*x2*y1 + 2*s*x2*y2 - y1^2 + 2*y1*y2 - y2^2==0,s)
s =
(x1*y2 - x1*y1 + x2*y1 - x2*y2 + 2*r*(- 4*r^2 + x1^2 - 2*x1*x2 + x2^2 + y1^2 - 2*y1*y2 + y2^2)^(1/2))/(4*r^2 - x1^2 + 2*x1*x2 - x2^2)
-(x1*y1 - x1*y2 - x2*y1 + x2*y2 + 2*r*(- 4*r^2 + x1^2 - 2*x1*x2 + x2^2 + y1^2 - 2*y1*y2 + y2^2)^(1/2))/(4*r^2 - x1^2 + 2*x1*x2 - x2^2)
So we have found the two possible slopes. We could go ahead and compute the intersection points, etc.
=======================================
#2. Basic geometry.
Given circles, centered at [x1,y1] and [x2,y2], each of radius r. Find the tangent points.
Answer: USE RIGHT TRIANGLES!
As we stated before, the intersection point of the lines happens at
[x0,y0] = [(x1 + x2)/2, (y1 + y2)/2]
The distance between the circle centers is
D = norm([x1,y1] - [x2,y2])
So the distance from the center of either circle to the mid-point is D/2.
The radius of each circle is r. And the line tangent to a circle MUST make a right triangle where it touches that circle as a tangent. The right triangle has hypotenuse of length D/2, one side of length r, and therefore the third side, by virtue of the pythagorean theorem has length...
L = sqrt(D^2/4 - r^2)
The angles of that triangle are now trivially found from a little trigonometry. How did it go? SOHCAHTOA. Easy, peasy.
Use method 2. It is a lot less messy.
  댓글 수: 3
John D'Errico
John D'Errico 2015년 1월 17일
Interestingly, I thought the analytical approach would be a lot cleaner. Then I thought of the geometrical approach, which is quite simple. I'm sure there are other solutions too though.
Mohamad Harb
Mohamad Harb 2021년 11월 20일
Hello dear, could anyone help me to get a solution for a problem? Having two touching circles, find the third one so it's touching both

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Brian
Brian 2019년 2월 12일
편집: Brian 2019년 2월 12일
I have made a pragmatic solution to do what is asked for based on these sources:
I tried finding a nicer solotion for the tangential points of the inner tangents, but I could not find it.
clc;
clear all;
close all;
% circle 1
x1 = 0;
y1 = 0.4;
r1 = 0.4;
% circle 2
x2 = 1;
y2 = 0;
r2 = 0.1;
% plotting the two circles
figure
circle_(x1,y1,r1,'k')
hold on
circle_(x2,y2,r2,'k')
axis equal
% The outer tangent lines https://en.wikipedia.org/wiki/Tangent_lines_to_circles
Deltax = x2-x1;
Deltay = y2-y1;
Deltar = r2-r1;
d = sqrt(Deltax^2+Deltay^2);
X = Deltax/d;
Y = Deltay/d;
R = Deltar/d;
k = 1;
a = R*X-k*Y*sqrt(1-R^2);
b = R*Y+k*X*sqrt(1-R^2);
c = r1-(a*x1 + b*y1);
x = -0.2:0.01:1.2;
y = (a*x + c)/(-b);
plot(x,y)
k = -1;
a = R*X-k*Y*sqrt(1-R^2);
b = R*Y+k*X*sqrt(1-R^2);
c = r1-(a*x1 + b*y1);
x = -0.2:0.01:1.2;
y = (a*x + c)/(-b);
plot(x,y)
%internal homothetic center https://en.wikipedia.org/wiki/Homothetic_center
hcx = r2/(r1+r2)*x1 + r1/(r1+r2)*x2;
hcy = r2/(r1+r2)*y1 + r1/(r1+r2)*y2;
plot(hcx,hcy,'*')
%tangent points on each cicle from a straight line going through the
%homothetic center.
%https://se.mathworks.com/matlabcentral/answers/86365-how-can-i-draw-a-tangent-line-from-a-given-point-to-a-circle-in-matlab
P = [hcx hcy]-[x1 y1];
d2 = dot(P,P);
Q0 = [x1 y1]+r1^2/d2*P;
T = r1/d2*sqrt(d2-r1^2)*P*[0,1;-1,0];
Q1_1 = Q0+T;
Q1_2 = Q0-T;
plot(Q1_1(1), Q1_1(2),'*')
plot(Q1_2(1), Q1_2(2),'*')
P = [hcx hcy]-[x2 y2];
d2 = dot(P,P);
Q0 = [x2 y2]+r2^2/d2*P;
T = r2/d2*sqrt(d2-r2^2)*P*[0,1;-1,0];
Q2_1 = Q0+T;
Q2_2 = Q0-T;
plot(Q2_1(1), Q2_1(2),'*')
plot(Q2_2(1), Q2_2(2),'*')
plot([Q1_1(1),Q2_1(1)], [Q1_1(2),Q2_1(2)],'-*')
plot([Q1_2(1),Q2_2(1)], [Q1_2(2),Q2_2(2)],'-*')
function circle_(x,y,r,opt)
th = 0:pi/50:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
plot(xunit, yunit, opt);
end

카테고리

Help CenterFile Exchange에서 Computational Geometry에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by