Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Smalest enclosing circle

  • To: mathgroup at
  • Subject: [mg50082] Re: Smalest enclosing circle
  • From: kzhang at (Kezhao Zhang)
  • Date: Sat, 14 Aug 2004 01:50:42 -0400 (EDT)
  • References: <cfi8tm$4p6$>
  • Sender: owner-wri-mathgroup at

Steve Gray <stevebg at> wrote in message news:<cfi8tm$4p6$1 at>...
> 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:

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.

  • Prev by Date: New user: Abs[] problem
  • Next by Date: Re: Smallest enclosing circle
  • Previous by thread: Re: Smalest enclosing circle
  • Next by thread: Re: Re: Smalest enclosing circle