-
Notifications
You must be signed in to change notification settings - Fork 1
/
Circleincircle.m
53 lines (47 loc) · 1.47 KB
/
Circleincircle.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
%inputting the values of the main circle
r1 = input(" enter the radius of FIRST(MAIN) circle:");
a = zeros(1,2);
c1=a;
c1(1,1)=input("Enter the x coordinate of the center with respect to origin:");
c1(1,2)=input("Enter the y coordinate of the center with respect to origin:");
x1=c1(1);
y1=c1(2);
centroid1 = c1;
area1=(pi*(r1^2));
%inputting the vales of the 2nd circle
r2 = input(" enter the radius of SECOND circle:");
b = zeros(1,2);
c2(1,1)=input("Enter the x coordinate of the center with respect to origin:");
c2(1,2)=input("Enter the y coordinate of the center with respect to origin:");
x2= c2(1);
y2= c2(2);
centroid2 = c2;
area2=(pi*(r2^2));
d = sqrt( (x2-x1)^2 + (y2-y1)^2 );
if r1 > ( d + r2 )
disp("SECOND circle is inside FIRST(MAIN) circle");
flag=1;
else
disp("SECOND circle is NOT inside FIRST(MAIN) circle");
end
if(flag==1)
disp("Centroid of the given figure:");
centroid=((centroid1*area1-centroid2*area2)/(area1-area2))
Cx=centroid(1);
Cy=centroid(2);
d1x = Cx-c1(1);
d1y = Cy-c1(2);
d2x = Cx-c2(1);
d2y = Cy-c2(2);
Ic1 = (4*pi*r1*r1*r1*r1)/16;
Ic2 = (4*pi*r2*r2*r2*r2)/16;
Icx = Ic1-Ic2+area1*d1x*d1x - area2*d2x*d2x;
Icy = Ic1-Ic2+area1*d1y*d1y - area2*d2y*d2y;
E= area1-area2;
disp("The MI along the centroidal axis:");
Ic = [Icx Icy]
Ixx= Icx+ E*Cx*Cx;
Iyy = Icy+E*Cy*Cy;
disp("The MI along X-axis and Y-axis");
I=[Ixx Iyy]
end