Re: Smalest enclosing circle
- To: mathgroup at smc.vnet.net
- Subject: [mg50082] Re: Smalest enclosing circle
- From: kzhang at flashmail.com (Kezhao Zhang)
- Date: Sat, 14 Aug 2004 01:50:42 -0400 (EDT)
- References: <cfi8tm$4p6$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Steve Gray <stevebg at adelphia.net> wrote in message news:<cfi8tm$4p6$1 at smc.vnet.net>... > 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 Here is one way to do it: Suppose the equation for the circle is (x-x0)^2+(y-y0)^2==r^2. We want to minimize r. Generate some points: In[]:=points=Partition[Table[Random[NormalDistribution[0,1]],{200}],2]; Constraints that all points are enclosed by the circle: In[]:= const=(#[[1]]-x0)^2+(#[[2]]-y0)^2<= r^2&/@points; Numerical minimization with constraints: In[]:=NMinimize[ Join[{r, r>0},const], {x0,y0, {r,5,10}}] Please note that it's better to provide some starting values for r otherwise NMinimize will complains that a starting value that doesn't satisfy the constraint is used. K. Z.
- Follow-Ups:
- Re: Re: Smalest enclosing circle
- From: DrBob <drbob@bigfoot.com>
- Re: Re: Smalest enclosing circle