Fix TriangleMesh::SamplePointsUniformly not sampling triangles unifor… #6653
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…mly (#6144)
Better uniform sampling of triangle meshes
Type
Motivation and Context
A problem was reported in the issue of uniform sampling not being really random nor uniform, as it iterated triangles deterministically and resulted in same triangle being picked many times in a row.
This change improves the situation by using
std::discrete_distribution
Checklist:
python util/check_style.py --apply
to apply Open3D code styleto my code.
updated accordingly.
It seems that the random generators are not exposed to Python? so Python docs were not updated only in source C++ docs (hopefully I did not miss something)
In case I'm unavailable later anyone is welcome to modify the PR, since most of the heavy lifting is done inside
std::discrete_distribution
anyways, any edits will hopefully be easy, also hopefully CI won't fail the changes are very non intrusiveDescription
Sample code based on original issue author
Original result reported in issue:
Example result after using
std::discrete_distribution
(note the result is random and will change every time we run, but you can see indeed it is much better now, much better than picking the same triangle every time, truly more random and uniform in terms of unit area on a mesh)