MathGroup Archive 2004

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

Search the Archive

Re: Smalest enclosing circle

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50075] Re: Smalest enclosing circle
  • From: "Dr. Wolfgang Hintze" <weh at snafu.de>
  • Date: Sat, 14 Aug 2004 01:50:26 -0400 (EDT)
  • References: <cfi8tm$4p6$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

My attempted solution

Remark: this is not the correct answer but it seems to be a good 
approximation to the truth - and it is very simple.

The main idea is "center of mass".

Step 1: calculate the center of mass. This will be the center of the circle
Step 2: determine the maximum difference of all points to the center of 
mass: this will be the radius of the circle

Create sample data (e.g. normally distributed around the
    origin)

In[27]:=
<< "Statistics`ContinuousDistributions`"

In[140]:=
pp = NormalDistribution[0, 1];

In[142]:=
n = 10;
px = RandomArray[NormalDistribution[0, 1], n];
py = RandomArray[NormalDistribution[0, 1], n];
points = Transpose[{px, py}];

Calculate location of center of mass ...

In[146]:=
c = {Mean[px], Mean[py]}

Out[146]=
{0.2679039580402966, -0.10697128218318264}

... and r as the maximum distance to the center

In[147]:=
dif = ((c - #1) . (c - #1) & ) /@ points;

In[154]:=
r = Sqrt[Max[dif]]

Out[154]=
1.5977195212803568

Show points and circle

In[155]:=
Show[{grpoints, Graphics[Circle[c, r]]},
    DisplayFunction -> $DisplayFunction,
    AspectRatio -> Automatic];

Looks quite nice. But isn't correct as usually the circle could be a bit 
smaller, as can be seen by the naked eye.

Regards,
Wolfgang

Steve Gray wrote:

> 	Given n points in the  plane, I want to find the smallest
> enclosing circle. Does anyone have Mathematica code to do this?
> 	I will be grateful for any tips.
> 
> Steve Gray
> 
> 


  • Prev by Date: Re: How does a notebook get its own filename or directory?
  • Next by Date: Re: Smalest enclosing circle
  • Previous by thread: Re: Re: Smalest enclosing circle
  • Next by thread: Re: Smalest enclosing circle