Ploting Intersection point of three circles
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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)))
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)))
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 commentaires
Réponse acceptée
John D'Errico
le 13 Juil 2022
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)
E13 = expand(E1 - E3)
E23 = expand(E2 - E3)
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])
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])
e23 = subs(E23,[x1 x2 x3 y1 y2 y3 r1 r2 r3],[2 5 4 8 5 9 10 12 9])
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)
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)
It looks qualitatively similar to what you have written. But at least my expression computes what I want it to compute. :)
Plus de réponses (1)
Sam Chak
le 13 Juil 2022
Modifié(e) : Sam Chak
le 13 Juil 2022
Hi @Talha Sami
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)))
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)))
plot(x, y, 'r*')
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!