forked from WaDelma/poisson
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Description
The library panics with an assertion failure when the radius parameter exceeds sqrt(2)/2 ≈ 0.707:
thread 'Compute Task Pool (4)' panicked at poisson/src/lib.rs:135:9:
assertion failed: radius <= NumCast::from(2f64.sqrt() / 2.).expect("Casting constant should always work.")
Expected Behavior
The library should handle this gracefully, either by:
- Clamping the radius to the maximum allowed value
- Returning an error through a Result type
- Documenting the constraint clearly in the Builder API
Current Behavior
The library uses an assertion that panics at runtime, which is not a graceful failure mode for what appears to be a mathematical constraint rather than a true invariant violation.
Reproduction
use poisson::{Builder, Type, algorithm::Ebeida};
use nalgebra::Vector2;
let radius = 0.8; // Exceeds sqrt(2)/2
let poisson = Builder::<_, Vector2<f32>>::with_radius(radius, Type::Normal);
let generator = poisson.build(rand::thread_rng(), Ebeida);
let points = generator.generate(); // Panics hereContext
This issue was encountered in townmaker when bounding boxes were too small relative to the density setting, causing the normalized radius calculation to exceed the limit.
Metadata
Metadata
Assignees
Labels
No labels