Sync changes from upstream repository

This commit is contained in:
Bozo the Builder
2024-04-03 04:03:44 -07:00
parent b939e2ac6b
commit 4034b523dd
17 changed files with 801 additions and 175 deletions

View File

@@ -428,3 +428,16 @@ void ON_RandomNumberGenerator::RandomPermutation(void* base, size_t nel, size_t
}
}
void ON_RandomNumberGenerator::TwoGaussians(double* u, double* v)
{
if (!u || !v) return;
double t = RandomDouble();
double s = RandomDouble();
// if there is a problem with the random number generator, we don't want to crash the FPU in the logarithm
if (t < 1e-20 || t > 1.0)
t = .5;
double m = sqrt(-2.0 * log(t));
*u = m * cos(ON_2PI * s);
*v = m * sin(ON_2PI * s);
}