Created
April 27, 2022 08:37
-
-
Save zeffii/06af8631258e387057acd79d753b73a6 to your computer and use it in GitHub Desktop.
bbox_simple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def basic_bbox(verts): | |
""" | |
input: | |
accepts verts as python iterables or as an np.array | |
verts = [v1, v2, v3, v3, ....] | |
or | |
verts = np.array(verts) | |
output: | |
if the function received an np.array as input it will also output a tuple of np.arrays | |
else it will output a tuple of two python-iterables | |
ultimately: ((min_x, min_y, min_z), (max_x, max_y, max_z)) | |
""" | |
np_mode = isinstance(verts, np.ndarray) | |
np_vec = verts if np_mode else np.array(verts) | |
bbox_max = np.amax(np_vec, axis=0) | |
bbox_min = np.amin(np_vec, axis=0) | |
return (bbox_min, bbox_max) if np_mode else (tuple(bbox_min), tuple(bbox_max)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment