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:
parent
7b070a86ad
commit
60b0d1d05d
@ -14,8 +14,9 @@
|
|||||||
#include "../point.hpp"
|
#include "../point.hpp"
|
||||||
#include "../vector.hpp"
|
#include "../vector.hpp"
|
||||||
|
|
||||||
|
#include <cruft/util/rand/distribution/normal.hpp>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <random>
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
|
|
||||||
@ -120,9 +121,9 @@ namespace cruft::geom {
|
|||||||
const auto c2 = c * c;
|
const auto c2 = c * c;
|
||||||
|
|
||||||
// generate a direction vector from a normally distributed random variable
|
// generate a direction vector from a normally distributed random variable
|
||||||
auto const x = std::normal_distribution<float> (0, a2) (generator);
|
auto const x = cruft::rand::distribution::normal<float> (0, a2) (generator);
|
||||||
auto const y = std::normal_distribution<float> (0, b2) (generator);
|
auto const y = cruft::rand::distribution::normal<float> (0, b2) (generator);
|
||||||
auto const z = std::normal_distribution<float> (0, c2) (generator);
|
auto const z = cruft::rand::distribution::normal<float> (0, c2) (generator);
|
||||||
|
|
||||||
// find the distance to the surface along the direction vector
|
// find the distance to the surface along the direction vector
|
||||||
auto const d = std::sqrt (x * x / a2 + y * y / b2 + z * z / c2);
|
auto const d = std::sqrt (x * x / a2 + y * y / b2 + z * z / c2);
|
||||||
|
Loading…
Reference in New Issue
Block a user