Code covered by the BSD License  

Highlights from
Minimal Bounding Box


4.9 | 7 ratings Rate this file 39 Downloads (last 30 days) File Size: 5.85 KB File ID: #18264
image thumbnail

Minimal Bounding Box



09 Jan 2008 (Updated )

Minimal bounding box around points in the (x,y,z) space

| Watch this File

File Information

With this function one can easily compute the minimal box (with right angles) around a set of points in 3d.

The extremal property of the box is determined either in terms of volume, surface or sum of edgelengths.

The calculation is based on heuristics only, but a huge number of tests did not show any counterexamples yet.

The algorithm behind the function is subdivided into three levels of accuracy with differing runtimes.

x = rand(10000,1);
y = rand(10000,1);
z = rand(10000,1);

tic;[rotmat,cornerpoints,volume,surface] = minboundbox(x,y,z,'v',3);toc
Elapsed time is 10.772170 seconds.

volume =
surface =

My thanks to John d'Errico and Roger Stafford for numerous discussions about proofs and algorithms in this context.

John also wrote minboundrect from the FEX, which heavily influenced this submission.

Also in this archive i included a small plot function (plotminbox) to show the resulting box via connecting the cornerpoints.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (7)
11 Jun 2014 Wolfgang  
18 Jan 2014 fourar redha  
17 Jan 2014 Matt Kindig

A simple fix to reduce the run-time is to replace the line:

rot_i = Rmat(-edgeangles(i));

with these lines:
theta = -edgeangles(i);
rot_i = [cos(theta), sin(theta); -sin(theta) cos(theta)];

In my testing, this reduces the run-time by a factor of ~2.

26 Dec 2013 Shunzhou  
30 May 2013 jia  
21 Jul 2011 Steven

Nice work. Thank you.

01 May 2011 Mark

This file saved me a ton of work, and has worked great for all of my tests, thanks!

Contact us