"michael" <bezenchu@gmail.com> wrote in message <i5a7r4$ocl$1@fred.mathworks.com>...
> i wanna find the cross points of 2 circles with center point and radius which changed each run.
> .........
           
I've decided to show you some matlab code that finds the two points of intersection of two circles. It should be more efficient and more easily understood than solutions generated automatically by 'solve'.
Assume that you are given the centers (x1,y1) and (x2,y2) with radii r1 and r2, respectively. Then do this:
dx = x2  x1; dy = y2  y1;
sr = r2 + r1; dr = r2  r1;
d2 = dx^2 + dy^2;
t = (sr^2  d2) * (d2  dr^2);
if t < 0, error('The circles do not intersect.'), end
t = sqrt(t)/(2*d2);
dx0 = dy * t; dy0 = dx * t;
t = dr * sr / d2;
x0 = (x1 + x2 + dx*t)/2;
y0 = (y1 + y2 + dy*t)/2;
x3 = x0 + dx0; y3 = y0 + dy0;
x4 = x0  dx0; y4 = y0  dy0;
The points (x3,y3) and (x4,y4) are the two intersections of the circles. As you move from center (x1,y1) to (x2,y2), the intersection (x3,y3) will be to the left and (x4,y4) to the right.
If the 't' in the line
t = (sr^2  d2) * (d2  dr^2);
is negative, that means the circles don't intersect and you will have to figure out how you want to proceed. In such a case the above solutions will be complexvalued.
Roger Stafford
