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
This commit is contained in:
Danny Robson 2020-12-09 08:20:11 +10:00
parent 7b070a86ad
commit 60b0d1d05d

View File

@ -14,8 +14,9 @@
#include "../point.hpp"
#include "../vector.hpp"
#include <cruft/util/rand/distribution/normal.hpp>
#include <cstdlib>
#include <random>
#include <iosfwd>
@ -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<float> (0, a2) (generator);
auto const y = std::normal_distribution<float> (0, b2) (generator);
auto const z = std::normal_distribution<float> (0, c2) (generator);
auto const x = cruft::rand::distribution::normal<float> (0, a2) (generator);
auto const y = cruft::rand::distribution::normal<float> (0, b2) (generator);
auto const z = cruft::rand::distribution::normal<float> (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);