Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return bounding boxes #4

Closed
krober10nd opened this issue Mar 25, 2020 · 3 comments
Closed

return bounding boxes #4

krober10nd opened this issue Mar 25, 2020 · 3 comments
Assignees

Comments

@krober10nd
Copy link

Hey,

Is is possible to return the corners of the bounding box for each leaf? I would like to use the decomposition of an input point set in another algorithm.

Thanks!

@kip-hart
Copy link
Owner

kip-hart commented Mar 28, 2020

Hi @krober10nd ,

Yes, it is possible. Each leaf contains an instance of the AABB class, which has the attribute limits. The corners can be derived from the limits using a function like this:

def limits2corners(limits):
    n_dim = len(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 list of 0s and 1s
        corner = [limits[d][ind] for d, ind in enumerate(inds)]
        corners.append(corner)
    return corners

I could add this as a property of the AABB class, then the corners of each leaf would be in self.aabb.corners for the leaf. Would that work?

@kip-hart kip-hart self-assigned this Mar 28, 2020
@krober10nd
Copy link
Author

Yes that would help! Thanks for that!

@kip-hart
Copy link
Owner

I added the corners property to the AABB class and updated to version 2.4.0. Thanks for the suggestion! Let me know if there are other features I could add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants