Effacer les filtres
Effacer les filtres

Finding the intersection of two circles useing solve

9 vues (au cours des 30 derniers jours)
Oli Rosna
Oli Rosna le 14 Nov 2013
Hello!
I have a problem, im trying to find the intersection of two circles useing solve. Not really sure how to do it, my code so far:
x=linspace (-6,6)
centerX1=13;
centerY1=3;
radie1=6;
centerX2=13;
centerY2=2;
radie2=5;
axis equal
hold on
th = 0:pi/50:2*pi;
xunit1 = radie1 * cos(th) + centerX1;
yunit1 = radie1 * sin(th) + centerY1;
h = plot(xunit1, yunit1);
hold on
xunit2 = radie1 * cos(th) + centerX2;
yunit2 = radie1 * sin(th) + centerY2;
h = plot(xunit2, yunit2);
clearvars x
syms x
y= solve(-x^2-26x-13^2-y^2-6y-22+x^2+26x+13^2+y^2+4y-17==0)
Im not really sure how this works so I though I could get some guide lines on the way so to speak :)

Réponses (1)

Christoph Feldkircher
Christoph Feldkircher le 4 Déc 2020
I know its been a while since you posted this question but maybe it can help somebody:
syms x y
A = [1 1]; %Center of Circle A
r_A = 10; %Radius of Circle A
B = [5 5]; %Center of Circle B
r_B = 11; %Radius of Circle B
Circle_1 = (x-A(1))^2 + (y-A(2))^2 - r_A^2;
Circle_2 = (x-B(1))^2 + (y-B(2))^2 - r_B^2;
temp = solve(Circle_1==0, Circle_2==0, x, y, 'Real', true);
intersect = [eval(temp.x(1)) eval(temp.x(2)); eval(temp.y(1)) eval(temp.y(2))];
hold on
axis equal
plot(intersect(1,1), intersect(2,1), 'g*');
plot(intersect(1,2), intersect(2,2), 'g*');
plot(A(1), A(2), 'r*');
plot(B(1), B(2), 'r*');
fimplicit(Circle_1, [-20,20]);
fimplicit(Circle_2, [-20,20]);

Catégories

En savoir plus sur Function Creation dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by