How to draw three circles with centers and radii given?
조회 수: 4 (최근 30일)
이전 댓글 표시
I have entered the data in this program and tried to draw three circles on same figure which would then give me their intersection in x and y but I can't cuz there is no command for circles. Kindly assist.
clc
clear all
close all
x1=2; y1=8; r1=10;
x2=5; y2=5; r2=12;
x3=4; y3=9; r3=9;
function circle(x,y,r);
h=plot(x
drawCircle([x1;x2], r1, 'r');
drawCircle([x2;y2], r2, 'g');
drawCircle([x3;y3], r3, 'b');
x=((y2-y1)*((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=((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))
plot(x,y)
댓글 수: 0
채택된 답변
Image Analyst
2022년 6월 27일
"I can't cuz there is no command for circles" <== there is if you have the Image Processing Toolbox.
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');
As far as determining intersection points, you'll have to use math for that. Or else use a distance formula on your (x,y) arrays.
댓글 수: 2
Image Analyst
2022년 7월 13일
You have to get the equation of a circle and set them equal to each other, like
(x-x1c).^2 + (y - y1c).^2 - R1^2 = (x-x2c).^2 + (y - y2c).^2 - R2^2
Then solve for x and y. It might be easier to do numerically than analytically but maybe not. You'd have to multiply it out, collect terms, etc. just like you'd solve any equation.
추가 답변 (1개)
KSSV
2022년 6월 27일
x1=2; y1=8; r1=10;
x2=5; y2=5; r2=12;
x3=4; y3=9; r3=9;
th = linspace(0,2*pi) ;
x = cos(th) ; y = sin(th) ;
figure
hold on
plot(x1+r1*cos(th),y1+r2*sin(th)) ;
plot(x2+r2*cos(th),y3+r2*sin(th)) ;
plot(x3+r1*cos(th),y3+r3*sin(th)) ;
axis equal
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!