trimesh icon indicating copy to clipboard operation
trimesh copied to clipboard

trimesh.bounds.oriented_bounds(mesh) documentation

Open matfcp opened this issue 2 years ago • 8 comments

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!

matfcp avatar Apr 01 '22 17:04 matfcp

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.

mikedh avatar Apr 01 '22 19:04 mikedh

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

matfcp avatar Apr 01 '22 20:04 matfcp

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.

matfcp avatar Apr 01 '22 20:04 matfcp

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 😄.

mikedh avatar Apr 01 '22 20:04 mikedh

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

matfcp avatar Apr 01 '22 20:04 matfcp

No worries thanks for looking into this in detail!

mikedh avatar Apr 01 '22 20:04 mikedh

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 avatar Apr 05 '22 15:04 mikedh

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😄

XieYHccc avatar Apr 07 '22 06:04 XieYHccc