From 60b0d1d05dce6f953bd4585c4bac36ace5634c99 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 9 Dec 2020 08:20:11 +1000 Subject: [PATCH] geom/ellipse: prefer our normal distribution for sampling The repeatability of a common implementation is relied upon by some client libraries which must run under libstdc++ and libcxx --- geom/ellipse.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/geom/ellipse.hpp b/geom/ellipse.hpp index 8ed89cc7..5437f802 100644 --- a/geom/ellipse.hpp +++ b/geom/ellipse.hpp @@ -14,8 +14,9 @@ #include "../point.hpp" #include "../vector.hpp" +#include + #include -#include #include @@ -120,9 +121,9 @@ namespace cruft::geom { const auto c2 = c * c; // generate a direction vector from a normally distributed random variable - auto const x = std::normal_distribution (0, a2) (generator); - auto const y = std::normal_distribution (0, b2) (generator); - auto const z = std::normal_distribution (0, c2) (generator); + auto const x = cruft::rand::distribution::normal (0, a2) (generator); + auto const y = cruft::rand::distribution::normal (0, b2) (generator); + auto const z = cruft::rand::distribution::normal (0, c2) (generator); // find the distance to the surface along the direction vector auto const d = std::sqrt (x * x / a2 + y * y / b2 + z * z / c2);