Skip to content

usman7384/OOBM_Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Convex Hull with Minimum Bounding Box (OOBM)

This Python script generates a set of random points, computes the convex hull of those points, and calculates the minimum bounding box (OOBM) around the convex hull. The bounding box is computed by considering all possible rotations of the convex hull and selecting the smallest bounding box.

The process is visualized using matplotlib to display the points, convex hull, and the computed minimum bounding boxes.

How It Works

  1. Random Point Generation: A set of random points is generated using NumPy's random number generator. The number of points is set by the variable no_of_points.

  2. Convex Hull Calculation: The convex hull of the points is calculated using the ConvexHull class from the scipy.spatial module. The convex hull is the smallest convex polygon that can enclose all the points.

  3. Bounding Box Calculation (OOBM): The function OOBM calculates the minimum bounding box that can enclose the convex hull. This is done by rotating the convex hull at different angles and calculating the bounding box for each rotation. The rotation that produces the smallest bounding box is selected.

  4. Plotting: The points, convex hull, and minimum bounding boxes are plotted using matplotlib. Each bounding box is drawn as a polygon, and the convex hull is outlined with lines connecting the points that form its boundary.

  5. Multiple Bounding Boxes: The script will plot multiple bounding boxes (10 in this case) to show the result of different rotations.

Usage

To run this script, simply execute it in your Python environment. The script will:

  1. Generate a random set of points.
  2. Calculate the convex hull of the points.
  3. Compute the minimum bounding box for the convex hull.
  4. Plot the points, convex hull, and bounding boxes.
python convex_hull_oobm.py

Output

The output will be a graphical plot displaying:

  • The randomly generated points (represented by circles).
  • The convex hull (outlined in black lines).
  • The minimum bounding boxes (represented by filled polygons).

The plot will contain multiple bounding boxes (10 in total) showing the results of the bounding box rotation.

About

Visualizing convex hulls and their minimum bounding boxes with random points in 2D space.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages