Re: intersection of two circles
- To: mathgroup at smc.vnet.net
- Subject: [mg105857] Re: [mg105850] intersection of two circles
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Tue, 22 Dec 2009 04:04:10 -0500 (EST)
- Reply-to: hanlonr at cox.net
Clear[intersect]
intersect[
{x1_?NumericQ, y1_?NumericQ, r1_?NumericQ},
{x2_?NumericQ, y2_?NumericQ, r2_?NumericQ}] :=
Module[{
dd = (x1 - x2)^2 + (y1 - y2)^2},
If[{x1, y1, r1} == {x2, y2, r2},
{(x - x1)^2 + (y - y1)^2 == r1^2},
If[ (r1 - r2)^2 <= dd <= (r1 + r2)^2,
{x, y} /. Solve[{(x - x1)^2 + (y - y1)^2 == r1^2,
(x - x2)^2 + (y - y2)^2 == r2^2}, {x, y}],
{}]]]
Points too far apart
intersect[{0, 0, 1}, {0, 3, 1}]
{}
One circle contains the other
intersect[{0, 0, 3}, {1, 0, 1}]
{}
Same circles
intersect[{0, 0, 1}, {0, 0, 1}]
{x^2 + y^2 == 1}
Circles intersect
intersect[{-1, 0, Sqrt[2]}, {1, 0, Sqrt[2]}]
{{0, -1}, {0, 1}}
{x1, y1, r1, x2, y2, r2} = RandomReal[{0, 1}, 6];
Graphics[{
Circle[{x1, y1}, r1],
Circle[{x2, y2}, r2],
Red, AbsolutePointSize[3],
Point[intersect[{x1, y1, r1}, {x2, y2, r2}]]}]
Bob Hanlon
---- Felix <f.becke at gmx.de> wrote:
=============
Hey,
I m already hours busy with trying to find a way to indicate the coordinates of the point(s) where two circles intersect.
Does Mathematica have a function that gives me the points of intersection if my input are the coordinates (in 2D) and the radii.
Thanks,
Felix