Exemplo n.º 1
0
/* >>>>>>>>>> EXA12_2 <<<<<<<<<< */
void exa12_2 (void)
{ float p = 3.14159f, step;
  
   setpag ("da4p");
   disini ();
   pagera ();
   hwfont ();
   axspos (200, 2400);
   axslen (1800, 1800);
   intax  ();

   titlin ("Surface Plot of the Parametric Function", 2);
   titlin ("[COS(t)+(3+COS(u)), SIN(t)*(3+COS(u)), SIN(u)]", 4);

   name   ("X-axis", "x");
   name   ("Y-axis", "y");
   name   ("Z-axis", "z");

   vkytit (-300);
   zscale (-1.f, 1.f);
   graf3d (-4.f, 4.f, -4.f, 1.f, -4.f, 4.f, -4.f, 1.f,
	   -3.f, 3.f, -3.f, 1.f);
   height (40);
   title  ();

   surmsh ("on");
   step = (float) (2 * 3.14159 / 30.);
   surfcp (zfun, 0.f, 2 * p, step, 0.f, 2 * p, step);
   disfin ();
}
Exemplo n.º 2
0
/* >>>>>>>>>> EX14_1 <<<<<<<<<< */
void ex14_1 (void)
{ int n = 50, i, j;
  double   fpi = 3.14159 / 180., step, x, y;
  float  zlev;

  step = 360. / (n - 1);

  for (i = 0; i < n; i++)
  { xray[i] = (float) (i * step);
    yray[i] = (float) (i * step);
  }

  for (i = 0; i < n; i++)
  { for (j = 0; j < n; j++)
    { x = xray[i] * fpi;
      y = yray[j] * fpi;    
      zmat[i][j] = (float) (2 * sin (x) * sin (y));
    }
  }

  setpag ("da4p");
  disini ();
  complx ();
  pagera ();

  titlin ("Contour Plot", 1);
  titlin ("F(X,Y) = 2 * SIN(X) * SIN(Y)", 3);

  name   ("X-axis", "x");
  name   ("Y-axis", "y");

  intax  ();
  axspos (450, 2670);
  graf   (0.f, 360.f, 0.f, 90.f, 0.f, 360.f, 0.f, 90.f);

  height (30);
  for (i = 0; i < 9; i++)
  { zlev = (float) (-2. + i * 0.5);
    setclr ((i + 1) * 25);
    if (i == 4)
      labels ("none", "contur"); 
    else
      labels ("float", "contur");

    contur  (xray, n, yray, n, (float *) zmat, zlev);
  }

  height (50);
  color  ("fore");
  title  ();
  disfin ();
}
Exemplo n.º 3
0
/* >>>>>>>>>> EX11_1 <<<<<<<<<< */
void ex11_1 (void)
{ int n = 50, i, j;
  double   fpi = 3.1415927 / 180., step, x, y;
  char   *cdev;

  step = 360. / (n - 1);
  for (i = 0; i < n; i++)
  { x = i * step;
    for (j = 0; j < n; j++)
    { y = j * step;
      zmat[i][j] = (float) (2 * sin (x * fpi) * sin (y * fpi));
    }
  }

  disini ();
  pagera ();
  cdev = getmfl ();
  hwfont ();

  titlin ("3-D Colour Plot of the Function", 2);
  titlin ("F(X,Y) = 2 * SIN(X) * SIN(Y)", 4);

  name   ("X-axis", "x");
  name   ("Y-axis", "y");
  name   ("Z-axis", "z");

  intax  ();
  autres (n, n);
  axspos (300, 1850);
  ax3len (2200, 1400, 1400);

  graf3  (0.f, 360.f, 0.f, 90.f, 0.f, 360.f, 0.f, 90.f,
          -2.f, 2.f, -2.f, 1.f);
  crvmat((float *) zmat, n, n, 1, 1);

  height (50);
  if (strcmp (cdev, "POST") == 0)
        psfont ("palatino-bolditalic");
  title  ();
  disfin ();
}
Exemplo n.º 4
0
/* >>>>>>>>>> EX13_4 <<<<<<<<<< */
void ex13_4 (void)
{ int n = 32, inray[32], icray[32], i;
  long ipray[32];

  for (i = 0; i < 32; i++)
  { inray[i] = i + 1;
    ipray[i] = 0;
    icray[i] = 1;
  }

  setpag ("da4p");
  disini ();
  setvlt ("small");
  pagera ();
  hwfont ();

  intax  ();
  ticks  (1, "xy");
  frame  (3);
  axslen (1600, 2200);
  axspos (400, 2700);

  name   ("Longitude", "x");
  name   ("Latitude", "y");
  titlin ("Conformal Conic Projection", 3);

  labels ("map", "xy");
  projct ("conf");
  grafmp (-10.f, 30.f, -10.f, 5.f, 35.f, 70.f, 35.f, 5.f);

  gridmp (1, 1);
  shdeur (inray, ipray, icray, n);

  height (50);
  title  ();
  disfin ();
}
Exemplo n.º 5
0
int main ( int argc, char *argv[] )

/******************************************************************************/
/*
  Purpose:

    MAIN demonstrates the use of bar graphs.

  Modified:
 
    09 April 2011

  Reference:

    Helmut Michels,
    The Data Plotting Software DISLIN - version 10.4,
    Shaker Media GmbH, January 2010,
    ISBN13: 978-3-86858-517-9.
*/
{
  static char cbuf[25];
  static char *ctit = "Bar Graphs (BARS)";
  int i;
  int nya = 2700;
  static float x[9]  = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 };
  static float y[9]  = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
  static float y1[9] = { 1.0, 1.5, 2.5, 1.3, 2.0, 1.2, 0.7, 1.4, 1.1 };
  static float y2[9] = { 2.0, 2.7, 3.5, 2.1, 3.2, 1.9, 2.0, 2.3, 1.8 };
  static float y3[9] = { 4.0, 3.5, 4.5, 3.7, 4.0, 2.9, 3.0, 3.2, 2.6 };

  printf ( "\n" );
  printf ( "DISLIN_EX05:\n" );
  printf ( "  C version:\n" );
  printf ( "  Demonstrate the display of data in bar graphs.\n" );
/*
  Specify the format of the output file.
*/
  metafl ( "png" );
/*
  Specify that if a file already exists of the given name,
  the new data should overwrite the old.
*/
  filmod ( "delete" );
/*
  Specify the name of the output graphics file.
*/
  setfil ( "dislin_ex05.png" );
/*
  Choose the page size and orientation.
*/
  setpag ( "usap" );
/*
  For PNG output, reverse the default black background to white.
*/
  scrmod ( "reverse" );
/*
  Open DISLIN.
*/
  disini ( );
/*
  Plot a border around the page.
*/
  pagera ( );
/*
  Use the COMPLEX font.
*/
  complx ( );
  ticks ( 1, "x" );
  intax ( );
  axslen ( 1600, 700 );
  titlin ( ctit, 3 );

  legini ( cbuf, 3, 8 );
  leglin ( cbuf, "FIRST", 1 );
  leglin ( cbuf, "SECOND", 2 );
  leglin ( cbuf, "THIRD", 3 );
  legtit ( " " );
  shdpat ( 5L );

  for ( i = 1; i <= 3; i++ )
  {
     if ( 1 < i )
     {
       labels ( "none", "x" );
     }
    axspos ( 300, nya-(i-1)*800 );

    graf ( 0.0, 10.0, 0.0, 1.0, 0.0, 5.0, 0.0, 1.0 );

    if ( i == 1 )
    {
      bargrp ( 3, 0.15 );
      color ( "red" );
      bars ( x, y, y1, 9 );
      color ( "green" );
      bars ( x, y, y2, 9 );
      color ( "blue" );
      bars ( x, y, y3, 9 );
      color ( "fore" );
      reset ( "bargrp" );
    }
    else if ( i == 2 )
    {
      height ( 30 );
      labels ( "delta", "bars" );
      labpos ( "center", "bars" );
      color ( "red" );
      bars ( x, y, y1, 9 );
      color ( "green" );
      bars ( x, y1, y2, 9 );
      color ( "blue" );
      bars ( x, y2, y3, 9 );
      color ( "fore" );
      reset ( "height" ); 
    }
    else if ( i == 3 )
    {
      labels ( "second", "bars" );
      labpos ( "outside", "bars" );
      color ( "red" );
      bars ( x, y, y1, 9 );
      color ( "fore" );
    }

    if ( i < 3 )
    {
      legend ( cbuf, 7 );
    }
    else
    {
      height ( 50 );
      title ( );
    }

    endgrf ( );
  }
/*
  Close DISLIN.
*/
  disfin ( );
/*
  Terminate.
*/
  printf ( "\n" );
  printf ( "DISLIN_EX05:\n" );
  printf ( "  Normal end of execution.\n" );

  return 0;
}
Exemplo n.º 6
0
/* >>>>>>>>>> EX10_1 <<<<<<<<<< */
void ex10_1 (void)
{ int nya = 2700, i;
  static char   *ctit = "Bar Graphs (BARS)", cbuf[25];

  static float x[9]  = {1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f},
               y[9]  = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f},
               y1[9] = {1.f, 1.5f, 2.5f, 1.3f, 2.0f, 1.2f, 0.7f, 1.4f, 1.1f},
               y2[9] = {2.f, 2.7f, 3.5f, 2.1f, 3.2f, 1.9f, 2.0f, 2.3f, 1.8f},
               y3[9] = {4.f, 3.5f, 4.5f, 3.7f, 4.0f, 2.9f, 3.0f, 3.2f, 2.6f};

  setpag ("da4p");
  disini ();
  pagera ();
  hwfont ();
  ticks  (1, "x");
  intax  ();;
  axslen (1600, 700);
  titlin (ctit, 3);

  legini (cbuf, 3, 8);
  leglin (cbuf, "FIRST", 1);
  leglin (cbuf, "SECOND", 2);
  leglin (cbuf, "THIRD", 3);
  legtit (" ");
  shdpat (5L);
  for (i = 1; i <= 3; i++)
  { if (i >  1) labels ("none", "x");
    axspos (300, nya - (i - 1) * 800);
    graf   (0.f, 10.f, 0.f, 1.f, 0.f, 5.f, 0.f, 1.f);

    if (i == 1)
    { bargrp (3, 0.15f);
      color  ("red");
      bars   (x, y, y1, 9);
      color  ("green");
      bars   (x, y, y2, 9);
      color  ("blue");
      bars   (x, y, y3, 9);
      color  ("fore");
      reset  ("bargrp");
    }
    else if (i == 2)
    { height (30);
      labels ("delta", "bars");
      labpos ("center", "bars");
      color  ("red");
      bars   (x, y, y1, 9);
      color  ("green");
      bars   (x, y1, y2, 9);
      color  ("blue");
      bars   (x, y2, y3, 9);
      color  ("fore");
      reset  ("height"); 
    }
    else if (i == 3)
    { labels ("second", "bars");
      labpos ("outside", "bars");
      color  ("red");
      bars   (x, y, y1, 9);
      color  ("fore");
    }

    if (i != 3) legend (cbuf, 7);

    if (i == 3)
    { height (50);
      title  ();
    }

    endgrf ();
  }
  disfin ();
}