How to draw three circles with centers and radii given?
6 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Image Analyst
on 27 Jun 2022
"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 Comments
Image Analyst
on 13 Jul 2022
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.
More Answers (1)
KSSV
on 27 Jun 2022
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 Comments
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!