Re: Fit rectangle to set of points

*To*: mathgroup at smc.vnet.net*Subject*: [mg69343] Re: Fit rectangle to set of points*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>*Date*: Thu, 7 Sep 2006 23:58:17 -0400 (EDT)*Organization*: The Open University, Milton Keynes, UK*References*: <edom0n$hu2$1@smc.vnet.net>

buttgereit at biomediclab.de wrote: > Dear Group, > > I have a set of 2D points given for which I would like to find the > smallest rectangle circumscribing all the points. > > Doing this with a circle instead of a rectangle was easy --- for the > rectangle I don't see the trick. > > Any hints? > > TIA + Best Regards, > > Peter > HI Peter, Do you mean something like that: In[1]:= pts = Table[Random[], {10}, {2}] Out[1]= {{0.830387, 0.0810041}, {0.123819, 0.121942}, {0.0578849, 0.938962}, {0.773195, 0.00453692}, {0.858906, 0.0116332}, {0.678336, 0.100916}, {0.862732, 0.780806}, {0.283974, 0.056643}, {0.600934, 0.766803}, {0.242359, 0.669791}} In[2]:= xleft = Min[pts[[All,1]]] Out[2]= 0.0578849 In[3]:= xright = Max[pts[[All,1]]] Out[3]= 0.862732 In[4]:= ybottom = Min[pts[[All,2]]] Out[4]= 0.00453692 In[5]:= ytop = Max[pts[[All,2]]] Out[5]= 0.938962 In[6]:= ListPlot[pts, Epilog -> {Line[{{xleft, ybottom}, {xleft, ytop}, {xright, ytop}, {xright, ybottom}, {xleft, ybottom}}]}]; Regards, Jean-Marc