<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Optimal Bounding Rectangle for given set of points. in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/optimal-bounding-rectangle-for-given-set-of-points/m-p/1873497#M27962</link>
    <description>yup... you are correct... thank for pointing that out.  8-).&lt;BR /&gt;
&lt;BR /&gt;
The problem though is that the bounding box you get with the method you suggest is Axis-Aligned to the WCS... what I want is the smallest bounding box...  !!  The smallest bounding box could be aligned with WCS then again it may not be aligned with any coordinate system defined in the drawing... however, once the smallest box is found, it could be used to create one.</description>
    <pubDate>Fri, 26 Jan 2007 18:19:39 GMT</pubDate>
    <dc:creator>mdhutchinson</dc:creator>
    <dc:date>2007-01-26T18:19:39Z</dc:date>
    <item>
      <title>Optimal Bounding Rectangle for given set of points.</title>
      <link>https://forums.autodesk.com/t5/vba-forum/optimal-bounding-rectangle-for-given-set-of-points/m-p/1873495#M27960</link>
      <description>I am working on developing an algorithm to determine a bounding rectangle (rotated away from WCS) for a given set of points. In my search, I stumbled on a couple web sites that look to have the logic I need (links below). It is the optimal bounding rectangle having the least area that encloses the set of points.&lt;BR /&gt;
&lt;BR /&gt;
http://cgm.cs.mcgill.ca/~orm/rotcal.html&lt;BR /&gt;
http://www.geometrictools.com/LibFoundation/Containment/Containment.html&lt;BR /&gt;
&lt;BR /&gt;
I think this (below) is in ‘html’ pseudo code…?&lt;BR /&gt;
Could someone convert this into English for me? … I would be most appreciative!&lt;BR /&gt;
… my apologies… for some reason the indentation using code blocks 'code' and '/code' didn’t work for this.&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
ordered vertices P(0) through P(N-1)&lt;BR /&gt;
define P(N) = P(0)&lt;BR /&gt;
minimumArea = infinity&lt;BR /&gt;
for (i = 1 i &amp;lt;= N i++)&lt;BR /&gt;
(&lt;BR /&gt;
U0 = P(i) - P(i-1)&lt;BR /&gt;
U0 /= U0.Length()&lt;BR /&gt;
U1 = (-U0.y,U0.x)&lt;BR /&gt;
s0 = t0 = s1 = t1 = 0&lt;BR /&gt;
for (j = 1 j &amp;lt; N j++)&lt;BR /&gt;
(&lt;BR /&gt;
D = P(j) - P(0)&lt;BR /&gt;
test = Dot(U0,D)&lt;BR /&gt;
if ( test &amp;lt; s0 ) s0 = test else if ( test &amp;gt; s1 ) s1 = test&lt;BR /&gt;
test = Dot(U1,D)&lt;BR /&gt;
if ( test &amp;lt; t0 ) t0 = test else if ( test &amp;gt; t1 ) t1 = test&lt;BR /&gt;
)&lt;BR /&gt;
area = (s1-s0)*(t1-t0)&lt;BR /&gt;
if ( area &amp;lt; minimumArea )&lt;BR /&gt;
minimumArea = area&lt;BR /&gt;
)&lt;BR /&gt;
[/code]</description>
      <pubDate>Fri, 26 Jan 2007 14:56:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/optimal-bounding-rectangle-for-given-set-of-points/m-p/1873495#M27960</guid>
      <dc:creator>mdhutchinson</dc:creator>
      <dc:date>2007-01-26T14:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: Optimal Bounding Rectangle for given set of points.</title>
      <link>https://forums.autodesk.com/t5/vba-forum/optimal-bounding-rectangle-for-given-set-of-points/m-p/1873496#M27961</link>
      <description>This will get the Box that surrounds an object. &lt;BR /&gt;
&lt;BR /&gt;
item.GetBoundingBox minPoint, maxPoint</description>
      <pubDate>Fri, 26 Jan 2007 18:09:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/optimal-bounding-rectangle-for-given-set-of-points/m-p/1873496#M27961</guid>
      <dc:creator>arcticad</dc:creator>
      <dc:date>2007-01-26T18:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: Optimal Bounding Rectangle for given set of points.</title>
      <link>https://forums.autodesk.com/t5/vba-forum/optimal-bounding-rectangle-for-given-set-of-points/m-p/1873497#M27962</link>
      <description>yup... you are correct... thank for pointing that out.  8-).&lt;BR /&gt;
&lt;BR /&gt;
The problem though is that the bounding box you get with the method you suggest is Axis-Aligned to the WCS... what I want is the smallest bounding box...  !!  The smallest bounding box could be aligned with WCS then again it may not be aligned with any coordinate system defined in the drawing... however, once the smallest box is found, it could be used to create one.</description>
      <pubDate>Fri, 26 Jan 2007 18:19:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/optimal-bounding-rectangle-for-given-set-of-points/m-p/1873497#M27962</guid>
      <dc:creator>mdhutchinson</dc:creator>
      <dc:date>2007-01-26T18:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Optimal Bounding Rectangle for given set of points.</title>
      <link>https://forums.autodesk.com/t5/vba-forum/optimal-bounding-rectangle-for-given-set-of-points/m-p/1873498#M27963</link>
      <description>Yup I see the limitation. Darn why is all their code in c++?</description>
      <pubDate>Fri, 26 Jan 2007 23:41:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/optimal-bounding-rectangle-for-given-set-of-points/m-p/1873498#M27963</guid>
      <dc:creator>arcticad</dc:creator>
      <dc:date>2007-01-26T23:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Optimal Bounding Rectangle for given set of points.</title>
      <link>https://forums.autodesk.com/t5/vba-forum/optimal-bounding-rectangle-for-given-set-of-points/m-p/1873499#M27964</link>
      <description>&amp;gt; Could someone convert this into English for me?&lt;BR /&gt;
&lt;BR /&gt;
Your algorithm will not work with any arbitrary set of points.  First&lt;BR /&gt;
you must find the minimum area bounding convex polygon (search&lt;BR /&gt;
for a "convex hull" algorithm).  The minimum area rectangle which&lt;BR /&gt;
contains your points will then have an edge on at least one of the&lt;BR /&gt;
edges of the bounding polygon.  For each edge of the bounding&lt;BR /&gt;
polygon, find the extent of its vertices in the direction of the edge&lt;BR /&gt;
and in a direction perpendicular to the edge.  Multiply these extents&lt;BR /&gt;
to get the area of the bounding rectangle aligned with the edge.&lt;BR /&gt;
Use the smallest area.  If you want the minimum area bounding&lt;BR /&gt;
rectangle instead of just its area you will have to save the extents&lt;BR /&gt;
as well as the area.</description>
      <pubDate>Sat, 27 Jan 2007 17:38:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/optimal-bounding-rectangle-for-given-set-of-points/m-p/1873499#M27964</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-01-27T17:38:31Z</dc:date>
    </item>
  </channel>
</rss>

