-
Notifications
You must be signed in to change notification settings - Fork 154
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
fix bug in PoissonDiskSampler, add test #186
Conversation
LGTM. @nmwsharp Should we be worried about this being a breaking change, e.g., for algorithms or demos that assume the original behavior (even it was wrong) in setting parameters, etc.? |
Also looks good to me -- thank you for adding tests too! One thing I've been meaning to do is to expose the distance parameter itself like @dyollb suggested, since in most cases it doesn't make much sense to have the minimum distance be in terms of the mesh's edge length. (I originally coded it up this way as a hacky proxy to a good "visual sampling density".) What do you all think? |
I pushed a small change to expose the mean edge length (fixes issue #183 ) |
Thank you for pointing this out, fixing it, and even adding a test!
This is definitely a bug, and it's somewhat-okay to make breaking changes for bugfixes. However, this is indeed the kind of change that would silently cause someone's code to stop working on update, and it's best to avoid those whenever possible. How about we also take the opportunity to factor out these options into a little options struct, and additionally include an (if this sounds like a good idea but others don't have time, I'd be happy to make this change) |
I added a struct for the options. Should we rename the options to something users might understand without reading the code? e.g., struct PoissonDiskOptions {
double relativeRadius = 1.0;
double absoluteRadius = -1.0;
int numCandidates = 30;
std::vector<SurfacePoint> pointsToAvoid;
int relativeAvoidanceRadius = 1;
bool use3DAvoidanceRadius = true;
}; |
Unfortunately, the test is flaky
I can try to modify the test so it is not flaky, or allow the user to set a seed for the random number generator. What do you think? |
I now set the seed in the test. Number of samples is identical for the scaled/unscaled square disk. |
Thanks @dyollb for adding the new feature! Agree that adding a struct for options is the way to go. I've streamlined the struct to only use distances specified world-space units, and updated the docs. The struct is now
I'm strongly in favor of using only absolute distances, to avoid confusion, and to let the user decide if they want to specify values in terms of edge length, etc. I've tested everything on my end, so if there's no other bugs/features we'd like to fix, I'll merge. |
LGTM. Maybe the options could have more expressive names, e.g., 'r' -> 'rsdius' or 'sample_distance', and 'rAvoidance' -> 'avoidance_radius' or 'avoidance_distance'. |
I've just merged. Thanks again for your help! |
Thanks a bunch @dyollb and @nzfeng, this is great!! I just rebuilt the docs, they're updated to show this change https://geometry-central.net/surface/algorithms/surface_sampling/ |
Fixed #184
Sampling only behaved reasonable when the mean edge length was close to 1, because the "rMinDist" was treated as if it where the squared min. distance (sqrt was taken).
This PR fixes this issue and adds a test.
In both cases we expect a similar number of points (seed cannot be set from API).
Without the fix, I get approx. 650 (width=1) vs 10 (width=100) points.