필터 지우기
필터 지우기

Finding the intersection of two circles useing solve

조회 수: 9 (최근 30일)
Oli Rosna
Oli Rosna 2013년 11월 14일
답변: Christoph Feldkircher 2020년 12월 4일
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 :)

답변 (1개)

Christoph Feldkircher
Christoph Feldkircher 2020년 12월 4일
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]);

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by