BLI_rand: add BLI_rng_get_float_unit_v2

This commit is contained in:
Campbell Barton 2014-06-14 18:12:19 +10:00
parent b54793ef02
commit 8d96ea8322
2 changed files with 8 additions and 0 deletions

View File

@ -50,6 +50,7 @@ int BLI_rng_get_int(struct RNG *rng);
unsigned int BLI_rng_get_uint(struct RNG *rng);
double BLI_rng_get_double(struct RNG *rng);
float BLI_rng_get_float(struct RNG *rng);
void BLI_rng_get_float_unit_v2(struct RNG *rng, float v[2]);
void BLI_rng_get_float_unit_v3(struct RNG *rng, float v[3]);
void BLI_rng_shuffle_array(struct RNG *rng, void *data, unsigned int elem_size_i, unsigned int elem_tot);

View File

@ -117,6 +117,13 @@ float BLI_rng_get_float(RNG *rng)
return (float) BLI_rng_get_int(rng) / 0x80000000;
}
void BLI_rng_get_float_unit_v2(RNG *rng, float v[2])
{
float a = (float)(M_PI * 2.0) * BLI_rng_get_float(rng);
v[0] = cosf(a);
v[1] = sinf(a);
}
void BLI_rng_get_float_unit_v3(RNG *rng, float v[3])
{
float r;