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

trimesh.bounds.oriented_bounds(mesh) documentation #1544

Open
matfcp opened this issue Apr 1, 2022 · 8 comments
Open

trimesh.bounds.oriented_bounds(mesh) documentation #1544

matfcp opened this issue Apr 1, 2022 · 8 comments

Comments

@matfcp
Copy link

matfcp commented Apr 1, 2022

Hey Mike, how you doing? Hope you're fine.

I'm working with this function trimesh.bounds.oriented_bounds(mesh) on my reasearch and would be of great help if you could give me some documentation, sources or some explanations about what methods it uses.

I'd appreciate if you could help me on this. Thank you!

@mikedh
Copy link
Owner

mikedh commented Apr 1, 2022

Hey Matheus, I don’t have a citation for you but the premise of the oriented_bounds function is that “the 3D oriented bounding box is guaranteed* to lie with one face on the convex hull,” and for a 2D outline “the minimum rectangle enclosing a polygon is guaranteed** to lie with one edge on the 2D convex hull of that polygon.” So the function basically takes the faces on the 3D hull, projects the vertices into 2D, and finds the 2D OBB of each of those, and returns the minimum volume result

*3D guarantee: not sure where I saw this and could be wrong
**2D guarantee: pretty confident about this, check out “rotating calipers” etc.

@matfcp
Copy link
Author

matfcp commented Apr 1, 2022

Thank you very much for your response. Don't you have any sources about the techniques that inspired you to develop the function?

@matfcp
Copy link
Author

matfcp commented Apr 1, 2022

In fact I don't really need the sources, but a more detailed explanation of what the function does so I can explain when I present the work on congresses. I kinda struggled to understand the source code but got little success on that.

@mikedh
Copy link
Owner

mikedh commented Apr 1, 2022

Hey, this article is pretty good: https://en.wikipedia.org/wiki/Minimum_bounding_box_algorithms

Reading it the 2D statement ("edge lies on the hull") is correct, but for 3D there are cases where we're going to return the wrong (or charitably, "approximate") result. Happy to take PR's to fix this! Or I'll add the word "approximate" to the docstring at some point 😄.

@matfcp
Copy link
Author

matfcp commented Apr 1, 2022

I'll read the article and try do understand it. Again, thank you so much for your response!

@matfcp matfcp closed this as completed Apr 1, 2022
@mikedh
Copy link
Owner

mikedh commented Apr 1, 2022

No worries thanks for looking into this in detail!

@mikedh
Copy link
Owner

mikedh commented Apr 5, 2022

Actually going to leave this open as I think at some point bounding_box_oriented should implement an exact OBB calculation. If it's going to return an approximate OBB, we could just as well use the mesh.principal_inertia_vectors which calculate very quickly. PR's very welcome from anyone 😄!

@mikedh mikedh reopened this Apr 5, 2022
@XieYHccc
Copy link

XieYHccc commented Apr 7, 2022

Hey Mike, could you please tell me what's the difference between the principal axis of inertia and vectors of the oriented bounding box ( assume the box is optimal)? I would very much appreciate it if you could easily explain this to me since I'm not good at phisics😄

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

3 participants