Add rng_xy()

This commit is contained in:
2025-09-23 15:36:08 +01:00
parent 0dccfcddea
commit cf8937cd6e
2 changed files with 8 additions and 0 deletions

View File

@@ -42,6 +42,13 @@ vec3_t rng_vec3(rng_t *rng)
return vec3_unit(v);
}
vec3_t rng_xy(rng_t *rng)
{
const double theta = 2.0 * M_PI * rng_canon(rng);
const double mag = rng_canon(rng);
return (vec3_t) { .x = mag * cos(theta), .y = mag * sin(theta) };
}
vec3_t rng_gaussian_xy(rng_t *rng, double stddev)
{
const double r1 = rng_canon(rng);