A..16 15_g_def_scale_3D_2.c

15_g_def_scale_3D_2.c

   1 #include<stdio.h>
   2 #include<glsc3d_3.h>
   3 #define WX     (600)
   4 #define WY     (600)
   5 
   6 #define XLEN    (2.0 * M_PI)
   7 #define YLEN    (2.0 * M_PI)
   8 #define ZLEN    (2.0 * M_PI)
   9 #define Imax    (100)
  10 #define Jmax    (100)
  11 
  12 int main()
  13 {
  14     g_init("Window", WX, WY);
  15     //  g_def_scale_3D_fix(0,
  16     //                     -XLEN / 2, XLEN / 2,
  17     //                     -YLEN / 2, YLEN / 2,
  18     //                     -ZLEN / 2, ZLEN / 2,
  19     //                     20.0, 20.0,
  20     //                     WX - 40.0, WY - 40.0);
  21     g_def_scale_3D(0,
  22                    -XLEN / 2, XLEN / 2,
  23                    -YLEN / 2, YLEN / 2,
  24                    -ZLEN / 4, ZLEN / 4,
  25                    -XLEN / 2, XLEN / 2,
  26                    -YLEN / 2, YLEN / 2,
  27                    -ZLEN / 2, ZLEN / 2,
  28                    20.0, 20.0,
  29                    WX - 40.0, WY - 40.0);
  30 
  31     double u[Imax][Jmax];
  32     double dx = XLEN / Imax, dy = YLEN / Jmax,rx,ry;
  33 
  34     for(int i = 0;i < Imax;i ++)
  35     {
  36         rx = (i + 0.5) * dx - XLEN / 2;
  37         for(int j = 0;j < Jmax;j ++)
  38         {
  39             ry = (j + 0.5) * dy - YLEN / 2;
  40             u[i][j] = sin(rx * ry) * 0.5;
  41         }
  42     }
  43     for (int i_time = 0;; i_time++)
  44     {
  45         g_cls();
  46         g_sel_scale(0);
  47         g_boundary();
  48         g_box_center_3D_core(0, 0, 0, XLEN, YLEN, ZLEN*0.5, 0, 1, 0);
  49         g_bird_view_3D(-XLEN / 2, XLEN / 2,
  50                        -YLEN / 2, YLEN / 2,
  51                        Imax, Jmax,
  52                        u, 0, 1);
  53         g_finish();
  54     }
  55     return 0;
  56 }



桂田 祐史