[Bf-blender-cvs] [8d96ea8] master: BLI_rand: add BLI_rng_get_float_unit_v2
Campbell Barton
noreply at git.blender.org
Sat Jun 14 10:45:00 CEST 2014
Commit: 8d96ea832247e4c457bb0f080c079e639a11c405
Author: Campbell Barton
Date: Sat Jun 14 18:12:19 2014 +1000
https://developer.blender.org/rB8d96ea832247e4c457bb0f080c079e639a11c405
BLI_rand: add BLI_rng_get_float_unit_v2
===================================================================
M source/blender/blenlib/BLI_rand.h
M source/blender/blenlib/intern/rand.c
===================================================================
diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h
index 045cadb..50ab50e 100644
--- a/source/blender/blenlib/BLI_rand.h
+++ b/source/blender/blenlib/BLI_rand.h
@@ -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);
diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c
index a5d6e2f..410f988 100644
--- a/source/blender/blenlib/intern/rand.c
+++ b/source/blender/blenlib/intern/rand.c
@@ -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;
More information about the Bf-blender-cvs
mailing list