Message 1 of 5
Optimal Bounding Rectangle for given set of points.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
http://cgm.cs.mcgill.ca/~orm/rotcal.html
http://www.geometrictools.com/LibFoundation/Containment/Containment.html
I think this (below) is in ‘html’ pseudo code…?
Could someone convert this into English for me? … I would be most appreciative!
… my apologies… for some reason the indentation using code blocks 'code' and '/code' didn’t work for this.
[code]
ordered vertices P(0) through P(N-1)
define P(N) = P(0)
minimumArea = infinity
for (i = 1 i <= N i++)
(
U0 = P(i) - P(i-1)
U0 /= U0.Length()
U1 = (-U0.y,U0.x)
s0 = t0 = s1 = t1 = 0
for (j = 1 j < N j++)
(
D = P(j) - P(0)
test = Dot(U0,D)
if ( test < s0 ) s0 = test else if ( test > s1 ) s1 = test
test = Dot(U1,D)
if ( test < t0 ) t0 = test else if ( test > t1 ) t1 = test
)
area = (s1-s0)*(t1-t0)
if ( area < minimumArea )
minimumArea = area
)
[/code]
http://cgm.cs.mcgill.ca/~orm/rotcal.html
http://www.geometrictools.com/LibFoundation/Containment/Containment.html
I think this (below) is in ‘html’ pseudo code…?
Could someone convert this into English for me? … I would be most appreciative!
… my apologies… for some reason the indentation using code blocks 'code' and '/code' didn’t work for this.
[code]
ordered vertices P(0) through P(N-1)
define P(N) = P(0)
minimumArea = infinity
for (i = 1 i <= N i++)
(
U0 = P(i) - P(i-1)
U0 /= U0.Length()
U1 = (-U0.y,U0.x)
s0 = t0 = s1 = t1 = 0
for (j = 1 j < N j++)
(
D = P(j) - P(0)
test = Dot(U0,D)
if ( test < s0 ) s0 = test else if ( test > s1 ) s1 = test
test = Dot(U1,D)
if ( test < t0 ) t0 = test else if ( test > t1 ) t1 = test
)
area = (s1-s0)*(t1-t0)
if ( area < minimumArea )
minimumArea = area
)
[/code]