Ploting Intersection point of three circles

조회 수: 14 (최근 30일)
Curious
Curious 2022년 7월 13일
댓글: Curious 2022년 7월 13일
x1=2; y1=8; r1=10;
x2=5; y2=5; r2=12;
x3=4; y3=9; r3=9;
viscircles([x1, y1], r1, 'Color', 'r');
viscircles([x2, y2], r2, 'Color', 'g');
viscircles([x3, y3], r3, 'Color', 'b');
hold on
x=(((x2-x3)*((x2^2-x1^2)+(y2^2-y1^2)+(r1^2-r2^2))-(x1-x2)*((x3^2-x2^2)+(y3^2-y2^2)+(r2^2-r3^2))))/(2*((y1-y2)*(x2-x3)-(y2-y3)*(x1-x2)))
x = -14.8889
y=(((y2-y3)*((y2^2-y1^2)+(x2^2-x1^2)+(r1^2-r2^2))-(y1-y2)*((y3^2-y2^2)+(x3^2-x2^2)+(r2^2-r3^2))))/(2*((x1-x2)*(y2-y3)-(x2-x3)*(y1-y2)))
y = -4.5556
plot(x , y,'r*')
I have this code with a mathematical expression to find the intersection point but as we can see the point is not through the circles. Kindly have a look at it or if someone can provide a better expression for this point.
  댓글 수: 6
Torsten
Torsten 2022년 7월 13일
Look at your three circles. They don't have a point in common.
Curious
Curious 2022년 7월 13일
@Torsten what if by some means we get a point by changing the centers and radii. I am curious how we get it.

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

채택된 답변

John D'Errico
John D'Errico 2022년 7월 13일
Why are you certain that forms the "intersection" point of the three circles? In fact, as the plot shows, there is no point where all three circles intersect, so it CANNOT be a point of a triply common intersection. In fact, in general, three somewhat arbitrarily generated circles will have no triply common point of intersection. I can guess what you did to form that expression, or perhaps you found it online, and misunderstood what it was going to compute, or perhaps you just mistyped what you found.
But first, I made a quick visual check that the code actually plotted the circles correctly, and then I realized that viscircles is part of the image processing TB. Oh well. :)
So, where does the formula you have come from? I am not certain. But now I'll show how to solve the problem.
Suppose we write out the equations of the three circles, then subtract them pairwise.
syms x y x1 x2 x3 y1 y2 y3 r1 r2 r3
E1 = (x - x1)^2 + (y - y1)^2 == r1^2;
E2 = (x - x2)^2 + (y - y2)^2 == r2^2;
E3 = (x - x3)^2 + (y - y3)^2 == r3^2;
E12 = expand(E1 - E2)
E12 = 
E13 = expand(E1 - E3)
E13 = 
E23 = expand(E2 - E3)
E23 = 
As you can see, we get three linear equations in the unknowns x and y. What do they correspond to?
Think of two circles. If they intersect, they will generally intersect in two points. We can connect those points with a line. Look carefully at the equation represented by E12, for example.
e12 = subs(E12,[x1 x2 x3 y1 y2 y3 r1 r2 r3],[2 5 4 8 5 9 10 12 9])
e12 = 
So E12 is just the straight line that connect the TWO points where circles E1 and E2 intersect. Similarly, E13 and E23 are also straight lines, connecting the two points of intersection of the corresponding circles.
e13 = subs(E13,[x1 x2 x3 y1 y2 y3 r1 r2 r3],[2 5 4 8 5 9 10 12 9])
e13 = 
e23 = subs(E23,[x1 x2 x3 y1 y2 y3 r1 r2 r3],[2 5 4 8 5 9 10 12 9])
e23 = 
For example, plot the three circles, and the linee we have generated. Do you see the line E12 is the line connecting those two points of intersection of circles 1 and 2? As well, E13 is the line connecting the two intersection points of circles 1 and 3, etc.
viscircles([2, 8], 10, 'Color', 'r');
viscircles([5, 5], 12, 'Color', 'g');
viscircles([4, 9], 9, 'Color', 'g');
axis equal
hold on
fimplicit(e12,'color','k')
fimplicit(e13,'color','k')
fimplicit(e23,'color','k')
[xsol,ysol] = solve(e12,e13,e23)
xsol = 
ysol = 
plot(double(xsol),double(ysol),'m*')
As you can see, the common intersection of the three lines need not happen where the three circles intersect in pairs. It is at best, someplace close to a triply common intersection. What mistake was made in the formulas you had is uncertain, but I won't bother to try to find the error you made out. At best, I can perhaps give you a formula for the above intersection.
[Xsol,Ysol] = solve(E12,E13,E23,x,y)
Xsol = 
Ysol = 
It looks qualitatively similar to what you have written. But at least my expression computes what I want it to compute. :)
  댓글 수: 1
Curious
Curious 2022년 7월 13일
@John D'Errico you explained it so well. I misunderstood it at first but you explained what I wanted to know. Hats off. Gracious

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

추가 답변 (1개)

Sam Chak
Sam Chak 2022년 7월 13일
편집: Sam Chak 2022년 7월 13일
Didn't change your code except for adding the minus signs and swapping the symbols in the two formulas. See @John D'Errico's explanations.
What exactly do you call this point? Technically, it is not called "Intersection Point" because the three circles do not physically intersect at this point. I have forgotten much about geometry. Perhap it is related to some kind of "Focal Point"?
x1=2; y1=8; r1=10;
x2=5; y2=5; r2=12;
x3=4; y3=9; r3=9;
viscircles([x1, y1], r1, 'Color', 'r');
viscircles([x2, y2], r2, 'Color', 'g');
viscircles([x3, y3], r3, 'Color', 'b');
hold on
y = -(((x2-x3)*((x2^2-x1^2)+(y2^2-y1^2)+(r1^2-r2^2))-(x1-x2)*((x3^2-x2^2)+(y3^2-y2^2)+(r2^2-r3^2))))/(2*((y1-y2)*(x2-x3)-(y2-y3)*(x1-x2)))
y = 14.8889
x = -(((y2-y3)*((y2^2-y1^2)+(x2^2-x1^2)+(r1^2-r2^2))-(y1-y2)*((y3^2-y2^2)+(x3^2-x2^2)+(r2^2-r3^2))))/(2*((x1-x2)*(y2-y3)-(x2-x3)*(y1-y2)))
x = 4.5556
plot(x, y, 'r*')

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by