MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: intersection of two circles

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105867] Re: intersection of two circles
  • From: Chris Degnen <degnen at cwgsy.net>
  • Date: Tue, 22 Dec 2009 04:06:07 -0500 (EST)
  • References: <hgno39$55l$1@smc.vnet.net>

On 21 Dec, 12:01, Felix <f.be... 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

The Circle-Circle Intersection page at MathWorld has a handy notebook
by Eric Weisstein.  Here are some of the functions from it (with minor
changes):


(* From PlaneGeometry.m in MathWorldPackages.zip at
http://library.wolfram.com/infocenter/MathSource/4775/ *)

Coordinates[point_Point] := First@point;

Intersections[Circle[{x1_, y1_}, r1_], Circle[{x2_, y2_}, r2_]] :=
    Module[{x, y, soln},
       soln = Solve[{
          	(x - x1)^2 + (y - y1)^2 == r1^2,
          	(x - x2)^2 + (y - y2)^2 == r2^2
          }, {x, y}];
       If[soln == {}, {},
    Point /@ (Chop[#, 10^-5] & /@ ({x, y} /. soln))]
   ];

(* From Circle-CircleIntersection.nb at
http://mathworld.wolfram.com/Circle-CircleIntersection.html *)

circ[2] = Circle @@@ {{{-1, 0}, 1}, {{1, 0}, 1}};
circ[3] = Circle @@@ {{{-1/2, 0}, 1}, {{1/2, 0}, 1}};
Print[Intersections @@@ {circ[2], circ[3]}];

cplot[c_List] := Module[{pts},
   Graphics[{
     c,
     RGBColor[1, 0, 0], pts = Intersections @@ c
     }, AspectRatio -> Automatic, Axes -> True,
    PlotLabel ->
     TraditionalForm /@ {0, \[PlusMinus] (Coordinates /@
           pts)[[-1, -1]]}]
   ];

Print[cplot[circ[2]]];
Print[cplot[circ[3]]];



  • Prev by Date: Re: Twitter.m (Twittering With Mathematica) broken?
  • Next by Date: 3d Mandelbulb Douady Julia
  • Previous by thread: Re: intersection of two circles
  • Next by thread: Re: Marbles.nb [was Re: CellChangeTimes?]