Skip to content

Commit

Permalink
Added corners property to AABB (#4) and bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
kip-hart committed Mar 28, 2020
1 parent 4d45dbe commit c0a5182
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions aabbtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,21 @@ def volume(self):
vol *= ub - lb
return vol

@property
def corners(self):
"""list: corner points of AABB"""

n_dim = len(self.limits)
f = '{:0' + str(n_dim) + 'b}'

n_corners = 2 ** n_dim
corners = []
for i in range(n_corners):
inds = [int(s) for s in f.format(i)] # convert i to binary list
corner = [self.limits[d][ind] for d, ind in enumerate(inds)]
corners.append(corner)
return corners

def overlaps(self, aabb):
"""Determine if two AABBs overlap
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def read(fname):

setup(
name='aabbtree',
version='2.3.1',
version='2.4.0',
license='MIT',
description='Pure Python implementation of d-dimensional AABB tree.',
long_description=read('README.rst'),
Expand Down Expand Up @@ -45,6 +45,7 @@ def read(fname):
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Mathematics',
],
Expand Down

0 comments on commit c0a5182

Please sign in to comment.