Bounding Boxes (bounding_boxes.py)

The bounding_boxes module computes axis-aligned bounding boxes (AABBs) for 2D points, segments, polygons, robot geometries, obstacles, and complete Scene instances.

Architectural Role & Sampler Integration

  • Sampling Domain Definition: Defines the spatial bounds [x_{\min}, x_{\max}] \times [y_{\min}, y_{\max}] within which sampling algorithms (UniformPointInBoundingBoxSampler) generate landmark configurations.

  • Margin Factor Inflation: Solvers apply a bounding margin width factor (bounding_margin_width_factor) to expand scene bounds slightly beyond obstacle extents, allowing robots to navigate around peripheral obstacles.

  • Broad-Phase Collision Culling: Used for fast AABB intersection tests before invoking expensive exact polygon or arrangement collision checks in discopygal.geometry_utils.collision_detection.

Key Functions

  • calc_scene_bounding_box(scene, margin_factor=1.0): Computes the tight bounding box enclosing all scene robots, start/goal positions, and obstacles, expanded by margin_factor.

  • calc_polygon_bounding_box(polygon): Computes (x_{\min}, y_{\min}, x_{\max}, y_{\max}) for a CGAL Polygon_2.

  • calc_points_bounding_box(points): Computes bounding bounds across a list of 2D points.

Usage Example

from discopygal.geometry_utils.bounding_boxes import calc_scene_bounding_box
from discopygal.solvers_infra import Scene

# Compute expanded scene bounding box with 10% safety margin
bbox = calc_scene_bounding_box(scene, margin_factor=1.1)
x_min, y_min, x_max, y_max = bbox

API Reference

class discopygal.geometry_utils.bounding_boxes.BoundingBox(min_x, max_x, min_y, max_y)

Bases: tuple

max_x

Alias for field number 1

max_y

Alias for field number 3

min_x

Alias for field number 0

min_y

Alias for field number 2

discopygal.geometry_utils.bounding_boxes.calc_scene_bounding_box(scene: Scene) BoundingBox

Get a DiscoPygal scene and compute its bounding box. The bounding box is computed as the smallest axis-aligned box that contains all the obstacles and robots.

Parameters:

scene (Scene) – scene

Returns:

min_x, max_x, min_y, max_y [bounds of the scene]

Return type:

(FT, FT, FT, FT)