Files
batomorph/src/rng.c
Camden Dixie O'Brien f4fcdc8a02 Implement RNG module
2025-09-23 15:35:26 +01:00

24 lines
355 B
C

#include "rng.h"
#include <limits.h>
#include <stdlib.h>
#include <sys/time.h>
void rng_init()
{
struct timeval tv;
gettimeofday(&tv, NULL);
srand(tv.tv_usec);
}
double rng_double()
{
return 2.0 * (double)rand() / (double)INT_MAX - 1.0;
}
vec3_t rng_vec3()
{
const vec3_t v = { rng_double(), rng_double(), rng_double() };
return vec3_unit(v);
}