A..3 2_VectorField.c

VectorField.c

   1 #include<stdio.h>
   2 #include<glsc3d_3.h>
   3 
   4 int main()
   5 {
   6     g_init("Window", 600, 600); //Pixel Size
   7     g_def_scale_2D(0,           //ID
   8                    -1, 1,       //xmin,xmax
   9                    -1, 1,       //ymin,ymax
  10                    20.0, 20.0,  //Window (Left, Top) Position
  11                    560, 560);   //Window Size (x,y)
  12     g_cls();                    //Clear window
  13     g_sel_scale(0);             //Select Virtual scale
  14     g_boundary();               //Draw Boundary
  15     int Imax = 10;
  16     int Jmax = 10;
  17     double VecX; double VecY;
  18     for(int i = 1; i < Imax; i ++)
  19     {
  20         for(int j = 1; j < Jmax; j ++)
  21         {
  22             double x = i*0.2 - 1.0, y = j*0.2 - 1.0;
  23             VecX = x; VecY = y;     // Divergence
  24             //VecX = -y; VecY = x;  // Rotation
  25             
  26             g_arrow_2D(x, y,        // Base Point
  27                        VecX, VecY,  // Direction
  28                        0.1,         // Size of Arrow Length
  29                        0.05,        // Size of Arrow Head
  30                        2);          // Arrow kinds
  31         }
  32     }
  33     g_finish();                 //flush Draw buffer
  34     g_sleep(10.0);              //Sleep 10 sec
  35     return 0;
  36 }



桂田 祐史