Skip to main content

AABBTree - Axis-Aligned Bounding Box Trees

Continuous Integration Coverage License

CMAME DOI

GitHub Repository ReadTheDocs Documentation PyPI PyPI

AABBTree is a pure Python implementation of a static d-dimensional axis aligned bounding box (AABB) tree. It is inspired by Introductory Guide to AABB Tree Collision Detection from Azure From The Trenches.

AABB Tree

Left: An AABB tree, leaves numbered by insertion order. Right: The AABBs and their bounding boxes.

Installation

AABBTree is available through PyPI and can be installed by running:

pip install aabbtree

To test that the package installed properly, run:

python -c "import aabbtree"

Alternatively, the package can be installed from source by downloading the latest release from the AABBTree repository on GitHub. Extract the source and, from the top-level directory, run:

pip install -e .

The --user flag may be needed, depending on permissions.

Example

The following example shows how to build an AABB tree and test for overlap:

>>> from aabbtree import AABB
>>> from aabbtree import AABBTree
>>> tree = AABBTree()
>>> aabb1 = AABB([(0, 0), (0, 0)])
>>> aabb2 = AABB([(-1, 1), (-1, 1)])
>>> aabb3 = AABB([(4, 5), (2, 3)])
>>> tree.add(aabb1, 'box 1')
>>> tree.does_overlap(aabb2)
True
>>> tree.overlap_values(aabb2)
['box 1']
>>> tree.does_overlap(aabb3)
False
>>> tree.add(aabb3)
>>> print(tree)
AABB: [(0, 5), (0, 3)]
Value: None
Left:
  AABB: [(0, 0), (0, 0)]
  Value: box 1
  Left: None
  Right: None
Right:
  AABB: [(4, 5), (2, 3)]
  Value: None
  Left: None
  Right: None

Documentation

Documentation for the project is available at https://aabbtree.readthedocs.io.

Contributing

Contributions to the project are welcome. Please visit the AABBTree repository to clone the source files, create a pull request, and submit issues.

Publication

If you use AABBTree in you work, please consider including this citation in your bibliography:

K. A. Hart and J. J. Rimoli, Generation of statistically representative microstructures with direct grain geomety control, Computer Methods in Applied Mechanics and Engineering, 370 (2020), 113242. (BibTeX) (DOI)

The incremental insertion method is discussed in section 2.2.2 of the paper.

Release files for aabbtree 2.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aabbtree 2.8.1
File Size Uploaded
aabbtree-2.8.1.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aabbtree 2.8.1
File Interpreter ABI Platform
aabbtree-2.8.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 25.6 kB

Release files / aabbtree-2.8.1.tar.gz

Download URL aabbtree-2.8.1.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e1f101461d153979f61c81dfea2e1a22c37aa6737e538b936c31eb1362ea04d5
BLAKE2b-256 checksum
How to use checksums
180523d4c869a595623cdaa0e7febb5caefcf101e2a8b315d0bc4cf2ce2fd100
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

Release files / aabbtree-2.8.1-py2.py3-none-any.whl

Download URL aabbtree-2.8.1-py2.py3-none-any.whl
Size 9.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
41166d4c9da095aa158589819dd3ca25dc36d11f027501efb32a9f902749cb17
BLAKE2b-256 checksum
How to use checksums
fd204bd161c75dea09946c8356961a0ef6abd762d9f1938483db7ed4c7617a13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

Release history Release notifications | RSS feed

This release

2.8.1 This release

2 release files

2.8.0

2 release files

2.7.0

2 release files

2.6.2

2 release files

2.6.1

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.4.0

1 release file

2.3.1

1 release file

2.3

1 release file

2.2

1 release file

2.1

1 release file

2.0.1

1 release file

2.0

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2

1 release file

1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page