[gegl] stress/c2g: use multiples of magic angle rather than random angles



commit 06f4956fed5d5a96041ca56562936b140b8f23aa
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Wed Jun 29 18:40:36 2011 +0100

    stress/c2g: use multiples of magic angle rather than random angles
    
    This can ensure slightly better distribution of angles used, and thus
    avoid some worst case scenarios for the random number generator.

 operations/common/envelopes.h |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/operations/common/envelopes.h b/operations/common/envelopes.h
index dc9a4b7..ecbb415 100644
--- a/operations/common/envelopes.h
+++ b/operations/common/envelopes.h
@@ -14,13 +14,13 @@
  * Copyright 2007, 2009 Ãyvind KolÃs     <pippin gimp org>
  */
 
-#define ANGLE_PRIME  95273  /* the lookuptables are sized as primes to avoid  */
-#define RADIUS_PRIME 29537  /* repetitions when they are used cyclcly simulatnously */
+#define ANGLE_PRIME  95273 /* the lookuptables are sized as primes to ensure */
+#define RADIUS_PRIME 29537 /* as good as possible variation when using both */
 
 static gfloat   lut_cos[ANGLE_PRIME];
 static gfloat   lut_sin[ANGLE_PRIME];
 static gfloat   radiuses[RADIUS_PRIME];
-static gdouble  luts_computed = 0.0; 
+static gdouble  luts_computed = 0.0;
 static gint     angle_no=0;
 static gint     radius_no=0;
 
@@ -28,6 +28,8 @@ static void compute_luts(gdouble rgamma)
 {
   gint i;
   GRand *rand;
+  gfloat magic_angle = atan(sqrt(2.0)); /* http://en.wikipedia.org/wiki/Magic_angle */
+  gfloat angle = 0.0;
 
   if (luts_computed==rgamma)
     return;
@@ -36,7 +38,7 @@ static void compute_luts(gdouble rgamma)
 
   for (i=0;i<ANGLE_PRIME;i++)
     {
-      gfloat angle = g_rand_double_range (rand, 0.0, G_PI*2);
+      angle += magic_angle;
       lut_cos[i] = cos(angle);
       lut_sin[i] = sin(angle);
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]