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!