gzz-commits
[Top][All Lists]
Advanced

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

[Gzz-commits] gzz/lava/gfx rd1.cxx


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/lava/gfx rd1.cxx
Date: Tue, 27 Aug 2002 09:40:17 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/08/27 09:40:17

Modified files:
        lava/gfx       : rd1.cxx 

Log message:
        Change all three parameters in the cube

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gfx/rd1.cxx.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: gzz/lava/gfx/rd1.cxx
diff -c gzz/lava/gfx/rd1.cxx:1.3 gzz/lava/gfx/rd1.cxx:1.4
*** gzz/lava/gfx/rd1.cxx:1.3    Mon Aug 26 11:26:03 2002
--- gzz/lava/gfx/rd1.cxx        Tue Aug 27 09:40:17 2002
***************
*** 5,23 ****
  
  //#define float double
  
! float eps = .02;
! float Du = 2E-5;
! float Dv = 1E-5;
  //#define F(i) 0.04
- #define k(i) 0.06
  #define F(i) F_arr[i]
! //#define k(i) k_arr[i]
  
  const int alln = 128;
  const int n0 = alln+2;
  const int n1 = alln+2;
  const int n2 = alln+2;
  
  const int e0 = 1;
  const int e1 = n0;
  const int e2 = n1 * n0;
--- 5,54 ----
  
  //#define float double
  
! #if 1
! /* 3D map */
! /* Note: x, y, z \in [0, 2\pi] */
! #define eps .02
! 
! //#define Du(i) 2E-5 / (eps*eps)
! #define Du(i) Du_arr[i]
! #define Du_init(x,y,z) exp(log(2E-5) + .7*triang2(z)) / (eps*eps)
! 
! #define Dv(i) 1E-5 / (eps*eps)
! 
  //#define F(i) 0.04
  #define F(i) F_arr[i]
! #define F_init(x,y,z) .04 - .04 * triang2(y)
! 
! //#define k(i) 0.06
! #define k(i) k_arr[i]
! #define k_init(x,y,z) .05 - .02 * triang2(x)
  
  const int alln = 128;
  const int n0 = alln+2;
  const int n1 = alln+2;
  const int n2 = alln+2;
  
+ #else 
+ /* Xmorphia map parameters */
+ #define LAPLACIAN_2D
+ 
+ #define eps .01
+ 
+ #define Du(i) 2E-5 / (eps*eps)
+ #define Dv(i) 1E-5 / (eps*eps)
+ 
+ #define F(i) F_arr[i]
+ #define F_init(x,y,z) .04 - .04 * triang2(y)
+ 
+ #define k(i) k_arr[i]
+ #define k_init(x,y,z) .05 - .02 * triang2(x)
+ 
+ const int n0 = 512+2;
+ const int n1 = 512+2;
+ const int n2 = 1+2;
+ #endif
+ 
  const int e0 = 1;
  const int e1 = n0;
  const int e2 = n1 * n0;
***************
*** 28,38 ****
--- 59,89 ----
  float *V2;
  float *F_arr;
  float *k_arr;
+ float *Du_arr;
+ float *Dv_arr;
  
  int iter;
  
  bool repaintRightaway = false;
  
+ // priod 2 pi
+ //  /\
+ // /  \   
+ //     \  /
+ //      \/
+ float triang(float x) {
+   return asin(sin(x))/M_PI_2;
+ }
+ 
+ // \ 
+ //   \
+ //     \
+ //       \
+ //
+ float triang2(float x) {
+   return 1-x/M_PI;
+ }
+ 
  void init() {
    // Initialize arrays
  
***************
*** 43,48 ****
--- 94,101 ----
  
    F_arr = new float[n0 * n1 * n2];
    k_arr = new float[n0 * n1 * n2];
+   Du_arr = new float[n0 * n1 * n2];
+   Dv_arr = new float[n0 * n1 * n2];
  
    for (int i = 0; i < n0 * n1 * n2; i++) {
  
***************
*** 53,60 ****
      U[i] = 0.5+0.5*sin(x + y + 3*z);
      V[i] = 0.5+0.5*sin(2 * y - 2*z);
  
!     F_arr[i] = +.05 + .05 * sin(x);
!     k_arr[i] = +.04 + .04 * sin(y);
    }
  
    iter = 0;
--- 106,123 ----
      U[i] = 0.5+0.5*sin(x + y + 3*z);
      V[i] = 0.5+0.5*sin(2 * y - 2*z);
  
! #ifdef k_init
!     k_arr[i] = k_init(x,y,z);
! #endif
! #ifdef F_init
!     F_arr[i] = F_init(x,y,z);
! #endif
! #ifdef Du_init
!     Du_arr[i] = Du_init(x,y,z);
! #endif
! #ifdef Dv_init
!     Dv_arr[i] = Dv_init(x,y,z);
! #endif
    }
  
    iter = 0;
***************
*** 97,112 ****
    copy2d(V, 0, e0 * (n0-2),  e1, n1, e2, n2);
    copy2d(V, e0 * (n0-1), e0, e1, n1, e2, n2);
  
  #define laplacian(a) (a[i-e0]+a[i+e0]+a[i-e1]+a[i+e1]+a[i-e2]+a[i+e2]-6*a[i])
  
    // Evaluate
-   float Du = ::Du / (eps * eps);
-   float Dv = ::Dv / (eps * eps);
- 
    int n = n0 * n1 * n2;
    for (int i = e2; i < n - e2; i++) {
!     U2[i] = U[i] + (Du * laplacian(U) - U[i] * V[i]*V[i] + F(i) * (1 - U[i]));
!     V2[i] = V[i] + (Dv * laplacian(V) + U[i] * V[i]*V[i] - (F(i)+k(i)) * 
V[i]);
    }
    
    // Swap
--- 160,176 ----
    copy2d(V, 0, e0 * (n0-2),  e1, n1, e2, n2);
    copy2d(V, e0 * (n0-1), e0, e1, n1, e2, n2);
  
+ #ifndef LAPLACIAN_2D
  #define laplacian(a) (a[i-e0]+a[i+e0]+a[i-e1]+a[i+e1]+a[i-e2]+a[i+e2]-6*a[i])
+ #else
+ #define laplacian(a) (a[i-e0]+a[i+e0]+a[i-e1]+a[i+e1]-4*a[i])
+ #endif
  
    // Evaluate
    int n = n0 * n1 * n2;
    for (int i = e2; i < n - e2; i++) {
!     U2[i] = U[i] + (Du(i) * laplacian(U) - U[i] * V[i]*V[i] + F(i) * (1 - 
U[i]));
!     V2[i] = V[i] + (Dv(i) * laplacian(V) + U[i] * V[i]*V[i] - (F(i)+k(i)) * 
V[i]);
    }
    
    // Swap
***************
*** 146,152 ****
  }
  
  
! float scale = .8f;
  float rotate[4] = {1,0,0,0};
  
  
--- 210,216 ----
  }
  
  
! float scale = 1.f;
  float rotate[4] = {1,0,0,0};
  
  
***************
*** 199,204 ****
--- 263,269 ----
  
    glTranslatef(-1, -1, -1);
    glScalef(2./(n0 - 2), 2./(n1-2), 2./(n2-2));
+   glTranslatef(-1, -1, -1);
  
    glPointSize(5);
    int i = 0;
***************
*** 207,218 ****
  
    static int through;
    through = through%(n2-2)+1;
!   for (int i2 = 0; i2 < n2; i2++)  
    {
!   int i = i2 * e2;
!   glBegin(GL_POINTS);
!     for (int i1 = 0; i1 < n1; i1++) 
!       for (int i0 = 0; i0 < n0; i0++) {
        if(U[i] < 0.4 || i2 == through) {
            bool stripe = 
                (i1 % 16 == 0) ||
--- 272,283 ----
  
    static int through;
    through = through%(n2-2)+1;
!   for (int i2 = 1; i2 < n2-1; i2++)  
    {
!     glBegin(GL_POINTS);
!     for (int i1 = 1; i1 < n1-1; i1++) {
!       int i = i1 * e1 + i2 * e2 + e0;
!       for (int i0 = 1; i0 < n0-1; i0++) {
        if(U[i] < 0.4 || i2 == through) {
            bool stripe = 
                (i1 % 16 == 0) ||
***************
*** 223,229 ****
        }
        i++;
        }
!   glEnd();
    }
  
    glPopMatrix();
--- 288,295 ----
        }
        i++;
        }
!     }
!     glEnd();
    }
  
    glPopMatrix();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]