       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:=
pts = Table[Random[], {10}, {2}]

Out=
{{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:=
xleft = Min[pts[[All,1]]]

Out=
0.0578849

In:=
xright = Max[pts[[All,1]]]

Out=
0.862732

In:=
ybottom = Min[pts[[All,2]]]

Out=
0.00453692

In:=
ytop = Max[pts[[All,2]]]

Out=
0.938962

In:=
ListPlot[pts, Epilog ->
{Line[{{xleft, ybottom}, {xleft, ytop},
{xright, ytop}, {xright, ybottom},
{xleft, ybottom}}]}];

Regards,
Jean-Marc

```

• Prev by Date: Re: Fit rectangle to set of points
• Next by Date: Re: numerical integration
• Previous by thread: Re: Fit rectangle to set of points
• Next by thread: Re: Fit rectangle to set of points