diff options
Diffstat (limited to 'src/sample')
-rw-r--r-- | src/sample/mod.rs | 5 | ||||
-rw-r--r-- | src/sample/uniform.rs | 5 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/sample/mod.rs b/src/sample/mod.rs index 84ac755..5095501 100644 --- a/src/sample/mod.rs +++ b/src/sample/mod.rs @@ -1,6 +1,5 @@ -use crate::Float; +use crate::{M_PI, Float}; use crate::core::{Vector3f, Vector2f}; -use std::f32::consts::PI; mod uniform; @@ -20,7 +19,7 @@ pub trait Sampler { fn get_unit_vector(&mut self) -> Vector3f { let s2d = self.get_sample_2d(); - let lambda = distribute_between(s2d.x, -PI, PI); + let lambda = distribute_between(s2d.x, -M_PI, M_PI); let costheta = 2.0 * s2d.y - 1.0; let sintheta = costheta.acos().sin(); diff --git a/src/sample/uniform.rs b/src/sample/uniform.rs index cc6825a..e2f0b7c 100644 --- a/src/sample/uniform.rs +++ b/src/sample/uniform.rs @@ -15,13 +15,14 @@ impl UniformSampler { pub fn new() -> Self { Self { r: Pcg32::seed_from_u64(1), - d: Uniform::from(0.0..1.0), + d: Uniform::new(0.0, 1.0), } } } impl Sampler for UniformSampler { fn get_sample(&mut self) -> Float { - self.d.sample(&mut self.r) + let sample = self.d.sample(&mut self.r); + sample } } |