Re: Fit rectangle to set of points

*To*: mathgroup at smc.vnet.net*Subject*: [mg69340] Re: [mg69330] Fit rectangle to set of points*From*: Stern <nycstern at gmail.com>*Date*: Thu, 7 Sep 2006 23:58:09 -0400 (EDT)*References*: <200609070830.EAA18142@smc.vnet.net>

Sounds like a homework problem, but I'll bite. I'm assuming you want to graph this. Format your data in a list of cartesian points {{1.1, 3.4},{4.5,9.17},...} Then create the rectangle box=Release[Hold[Module[{top, bottom, left, right}, top = Max[Transpose[data][[2]]]; bottom = Min[ Transpose[data][[2]]]; left = Max[Transpose[data][[1]]]; right = Min[Transpose[data][[ 1]]]; Line[{{left, bottom}, {left, top}, {right, top}, {right, bottom}, {left, bottom}}]]] /. data -> WHATEVER] Then create the dots dots=Release[Hold[Map[Point[#] &, data]] /. data -> WHATEVER] And finally, Show[Graphics[box], Graphics[dots]] Have fun! On 9/7/06, buttgereit at biomediclab.de <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 > >

**References**:**Fit rectangle to set of points***From:*"buttgereit@biomediclab.de" <buttgereit@biomediclab.de>