Circle-Circle Intersection ,dimension between circles

Hi every one I have question ,I hope if some help me to get answer as image shows I have two circles in different diameter with centers point A and B where is C point center of gravity for hatched area and I know dimension between point C and B (D3) and I know diameters of two circles
what I need to calculate dimension between point A and B (D1) or dimension between point A and C (D2)
Can any one help me ???
thanks alot

 Accepted Answer

I don't know what is your D3. So go to the bottom of the code and set D3 to the one that you have.
% Area of a circular segment
A_CS=@(theta,r) ( (r^2/2)*(theta-sin(theta)) );
% Center of mass of a circular segment
X_CS=@(theta,r) ( (4*r*sin(theta/2)^3)/(3*(theta-sin(theta))) );
% x/y of circle-circle intersect
% It is assumed the coordinate system is at the center of the circle on the right
% r1 is the radius of the circle on the right,
% r2 is the radius of the circle on the left.
% d is the distance between the two centers.
xInt=@(r1,r2,d) ( (d^2-r2^2+r1^2)/(2*d) );
yInt=@(r1,r2,d) ( sqrt( (4*d^2*r1^2-(d^2-r2^2+r1^2)^2)/(4*d^2) ) );
theta1=@(x,y) atan(y/x);
theta2=@(x,y,d) atan( y / (d-x) );
Nom=@(r1,r2,d) ( d*pi*r2^2 ...
- A_CS(theta1(xInt(r1,r2,d),yInt(r1,r2,d)),r1)*X_CS(theta1(xInt(r1,r2,d),yInt(r1,r2,d)),r1) ...
- A_CS(theta2(xInt(r1,r2,d),yInt(r1,r2,d),d),r2)*(d-X_CS(theta2(xInt(r1,r2,d),yInt(r1,r2,d),d),r2)) );
Denom= @(r1,r2,d) ( pi*r2^2 ...
- A_CS(theta1(xInt(r1,r2,d),yInt(r1,r2,d)),r1) ...
- A_CS(theta2(xInt(r1,r2,d),yInt(r1,r2,d),d),r2) );
xHatch=@(r1,r2,d) (Nom(r1,r2,d)/Denom(r1,r2,d));
%%SET THESE NUMBERS ACCORDINGLY
r1=50/2; %[50mm]
r2=52/2; %[52mm]
D3=40; %[80mm]
%solving for D1
[D1,fval] = fsolve(@(d1) (D3-xHatch(r1,r2,d1)), D3-1 );
D2=D3-D1;
ezplot(@(x,y) (x.^2+y.^2-r1.^2),[-r1, D1+r2,-max(r1,r2),max(r1,r2)])
hold on
ezplot(@(x,y) ((x-D1).^2+y.^2-r2.^2),[-r1, D1+r2,-max(r1,r2),max(r1,r2)])
title('')
axis equal
line([xInt(r1,r2,D1) xInt(r1,r2,D1)],ylim,'Color','r')
Just note that I don't check if the r1 and r2 and D3 are valid numbers. I am assuming that they are valid. For example if D3 > (r1+r2) there is no solution at all and this program generates an error or gives a wrong answer. So make sure that the numbers are set properly. Also if the left circle is too much inside the the right circle this code gives you wrong answer. Make sure that D1<D3 at the end. and xInt(r1,r2,D1)>0;

4 Comments

Hi Mohammad Abouali, thank you very much for your reply ,I will try this code but I have question about code!!
% Center of mass of a circular segment
X_CS=@(theta,r) ( (4*r*sin(theta/2)^3)/(3*(theta-sin(theta))) );
as I understood this equation gives distance between center of circle and center of mass of a circular segment (D2)???? I don't have any information about equation to calculate that but I think (d ,r1,r2) should be in equation????
and in code
%solving for D1
[D1,fval] = fsolve(@(d1) (D3-xHatch(r1,r2,d1)), D3-1 )
why you use "D3-1"??
about D3 value it will be calculated by another function then it will be passed to this function thank you again for your help
The last function, i.e. xHatch gives the location of C relative to B, i.e. D3, based on the known radius of the circles, i.e. r1 and r2, and known distance of the circles, i.e. AB or D1. (I know D1 is your unknown, so read through)
D3=xHatch(r1,r2,d), where r1 is the radius of the left circle, r2 is the radius of the right circle and d is the distance between the center of these two circles, i.e. D1.
r1 and r2 are known but as you mentioned you don't have d or (D1). therefore I use "FSOLVE" to solve f=@(D1) (D3-xHatch(r1,r2,D1)).
when passing this to "FSOLVE", matlab changes D1 until the function F is zero, i.e. we find a correct D1 that gives us the D3 that we know.
"FSOLVE" requires an initial value to start, We know that D1<D3, so as initial guess I give D3-1. number one is completely arbitrary.
the X_CS equation, i.e. center of mass of circular segment, is defined at http://en.wikipedia.org/wiki/List_of_centroids. Check that. That is one of the key assumption, if the two circle are too much overlapping until the two lenses are not anymore following this assumption you should not use this code. Two checks that you can make is that make sure D1<D3 at the end and xInt is not negative, so the line (red line in the graph that my code generates) falls on the right hand side of B and on the left hand side of A.
thank you very much for your help ,it is very helpful

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics 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!