summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
Diffstat (limited to 'math.c')
-rw-r--r--math.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/math.c b/math.c
index d1f30dc..c7ac64b 100644
--- a/math.c
+++ b/math.c
@@ -176,7 +176,10 @@ static inline float randf(void) {
static float rand_gauss(void) {
// https://en.wikipedia.org/wiki/Normal_distribution#Generating_values_from_normal_distribution
- float U = randf(), V = randf();
+ float U, V;
+ do
+ U = randf(), V = randf();
+ while (U == 0 || V == 0);
return sqrtf(-2 * logf(U)) * cosf(TAUf * V);
}