DISLIN Examples / C

Demonstration of CURVE / C

#include <stdio.h>
#include <math.h>
#include "dislin.h"

int main ()
{ int n = 100, i, ic;
  double fpi = 3.1415926 / 180.0, step, x;
  float  xray[100], y1ray[100], y2ray[100];

  step = 360. / (n - 1);

  for (i = 0; i < n; i++)
  { xray[i] = (float) (i * step);
    x = xray[i] * fpi;
    y1ray[i] = (float) sin (x);
    y2ray[i] = (float) cos (x);
  }

  metafl ("cons");
  scrmod ("revers");
  disini ();
  pagera ();
  complx ();
  axspos (450, 1800);
  axslen (2200, 1200);

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

  labdig (-1, "x");
  ticks  (9, "x");
  ticks  (10, "y");

  titlin ("Demonstration of CURVE", 1);
  titlin ("SIN(X), COS(X)", 3);

  ic =   intrgb (0.95,0.95,0.95);
  axsbgd (ic);

  graf   (0.0, 360.0, 0.0, 90.0, -1.0, 1.0, -1.0, 0.5);
  setrgb (0.7, 0.7, 0.7);
  grid   (1, 1);

  color  ("fore");
  height (50);
  title  ();

  color  ("red");
  curve  (xray, y1ray, n);
  color  ("green");
  curve  (xray, y2ray, n);
  disfin ();
  return 0;
}

Polar Plots / C

#include <stdio.h>
#include <math.h>
#include "dislin.h"

int main ()
{ int n = 300, m = 10, i, ic;
  double f = 3.1415926 / 180.0, step, a;
  float  xray[300], yray[300], x2[10], y2[10];

  step = 360. / (n - 1);

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

  for (i = 0; i < m; i++)
  { x2[i] = i + 1;
    y2[i] = i + 1;
  }

  setpag ("da4p");
  metafl ("cons");
  scrmod ("revers");
  disini ();
  pagera ();
  hwfont ();
  axspos (450,1800);

  titlin ("Polar Plots", 2);
  ticks  (3, "Y");
  axends ("NOENDS", "X");
  labdig (-1, "Y");
  axslen (1000, 1000);
  axsorg (1050, 900);

  ic = intrgb (0.95, 0.95, 0.95);
  axsbgd (ic);
 
  grafp  (1.0, 0.0, 0.2, 0.0, 30.0);
  color  ("blue");
  curve  (xray, yray, n);
  color  ("fore");
  htitle (50);
  title  ();
  endgrf ();

  labdig (-1, "X");
  axsorg (1050, 2250);
  labtyp ("VERT", "Y");
  grafp  (10.0, 0.0, 2.0, 0.0, 30.0);
  barwth (-5.0);
  polcrv ("FBARS");
  color  ("blue");
  curve  (x2, y2, m);
  disfin ();
  return 0;
}


Symbols / C

#include <stdio.h>
#include "dislin.h"

int main ()
{ int nl, ny, i, nxp;
  char ctit[] = "Symbols", cstr[80];

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

  height (60);
  nl = nlmess (ctit);
  messag (ctit, (2100 - nl) / 2, 200);

  height (50);
  hsymbl (120);

  ny = 150;

  for (i = 0; i < 24; i++)
  { if ((i % 4) == 0) 
    { ny  += 400;
      nxp  = 550;
    }
    else
    { nxp += 350;
    }

    nl = intcha (i, cstr);
    nl = nlmess (cstr) / 2;
    messag (cstr, nxp - nl, ny + 150);
    symbol (i, nxp, ny);
  }
  disfin ();
  return 0;
}


Interpolation Methods / C

#include <stdio.h>
#include "dislin.h"

int main ()
{ int nya = 2700, i, nx, ny, ic;
  float  x[] = {0.0, 1.0, 3.0, 4.5, 6.0, 8.0, 9.0, 11.0, 12.0, 12.5,
                13.0, 15.0, 16.0, 17.0, 19.0, 20.0},
         y[] = {2.0, 4.0, 4.5, 3.0, 1.0, 7.0, 2.0, 3.0, 5.0, 2.0, 2.5,
                2.0, 4.0, 6.0, 5.5, 4.0};
  char *cpol[6] = {"SPLINE", "STEM", "BARS", "STAIRS", "STEP", "LINEAR"};
  char *ctit    = "Interpolation Methods";

  setpag ("da4p");
  metafl ("cons");
  scrmod ("revers");
  disini ();
  complx ();
  pagera ();
  incmrk (1);
  hsymbl (25);
  titlin (ctit, 2);
  axslen (1500, 350);
  setgrf ("line", "line", "line", "line");
  ic = intrgb (1.0, 1.0, 0.0);
  axsbgd (ic);

  for (i = 0; i < 6; i++)
  { axspos (350, nya - i * 350);
    polcrv (cpol[i]);
    marker(16);

    graf   (0.0, 20.0, 0.0, 5.0, 0.0, 10.0, 0.0, 5.0);
    nx = nxposn (1.0);
    ny = nyposn (8.0);
    messag (cpol[i], nx, ny);
    color  ("red");
    curve  (x, y, 16);
    color  ("fore");

    if (i == 5)
    { height (50);
      title  ();
    }
    endgrf ();
  }
  disfin ();
  return 0;
}

Bar Graphs / C

#include <stdio.h>
#include "dislin.h"

int main ()
{ int nya = 2700, i;
  char   *ctit = "Bar Graphs (BARS)", cbuf[25];

  float  x[9]  = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0},
         y[9]  = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
         y1[9] = {1.0, 1.5, 2.5, 1.3, 2.0, 1.2, 0.7, 1.4, 1.1},
         y2[9] = {2.0, 2.7, 3.5, 2.1, 3.2, 1.9, 2.0, 2.3, 1.8},
         y3[9] = {4.0, 3.5, 4.5, 3.7, 4.0, 2.9, 3.0, 3.2, 2.6};

  setpag ("da4p");
  metafl ("cons");
  disini ();
  pagera ();
  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 (5);
  for (i = 1; i <= 3; i++)
  { if (i >  1) 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);

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

    endgrf ();
  }
  disfin ();
  return 0;
}

Pie Charts / C

#include <stdio.h>
#include "dislin.h"

int main ()
{ int nya = 2800, i;
  char     *ctit = "Pie Charts (PIEGRF)", cbuf[41];
  float  xray[5] = {1.0, 2.5, 2.0, 2.7, 1.8};

  setpag ("da4p");
  metafl ("cons");
  disini ();
  pagera ();
  complx ();
  axslen (1600, 1000);
  titlin (ctit, 2);
  chnpie ("both");

  legini (cbuf, 5, 8);
  leglin (cbuf, "FIRST", 1);
  leglin (cbuf, "SECOND", 2);
  leglin (cbuf, "THIRD", 3);
  leglin (cbuf, "FOURTH", 4);
  leglin (cbuf, "FIFTH", 5);

  patcyc (1, 7);
  patcyc (2, 4);
  patcyc (3, 13);
  patcyc (4, 3);
  patcyc (5, 5);

  for (i = 0; i < 2; i++)
  { axspos (250, nya - i * 1200);
    if (i == 1)
    { labels ("data", "pie");
      labpos ("external", "pie");
    }

    piegrf (cbuf, 1, xray, 5);

    if (i == 1)
    { height (50);
      title  ();
    }
    endgrf ();
  }
  disfin ();
  return 0;
}


3-D Bar Graph / 3-D Pie Chart / C

#include <stdio.h>
#include "dislin.h"

int main ()
{ char cbuf[80];
  float  xray[5]  = {2.0, 4.0, 6.0, 8.0, 10.0},
         y1ray[5] = {0.0, 0.0, 0.0, 0.0, 0.0},
         y2ray[5] = {3.2, 1.5, 2.0, 1.0, 3.0};
  int  ic1ray[5]  = {50, 150, 100, 200, 175},
       ic2ray[5]  = {50, 150, 100, 200, 175};

  setpag ("da4p");
  metafl ("cons");
  disini ();
  pagera ();
  hwfont ();

  titlin ("3-D Bar Graph / 3-D Pie Chart", 2);
  htitle (40);

  shdpat (16);
  axslen (1500, 1000);
  axspos (300, 1400);

  barwth (0.5);
  bartyp ("3dvert");
  labels ("second", "bars");
  labpos ("outside", "bars");
  labclr (255, "bars");
  graf   (0.0, 12.0, 0.0, 2.0, 0.0, 5.0, 0.0, 1.0);
  title  ();
  color  ("red");
  bars   (xray, y1ray, y2ray, 5);
  endgrf ();

  shdpat (16);
  labels ("data", "pie");
  labclr (255, "pie");
  chnpie ("none");
  pieclr (ic1ray, ic2ray, 5);
  pietyp ("3d");
  axspos (300, 2700);
  piegrf (cbuf, 0, y2ray, 5);       
  disfin ();
  return 0;
}


3-D Bars / BARS3D / C

#include <stdio.h>
#include "dislin.h"

#define N 18

int main ()
{ float xwray[N],ywray[N];
  int  i;
  char cbuf[80];
  float  xray[N]  = {1.0, 3.0, 8.0, 1.5, 9.0, 6.3, 5.8, 2.3, 8.1, 3.5,
                     2.2, 8.7, 9.2, 4.8, 3.4, 6.9, 7.5, 3.8};
  float  yray[N]  = {5.0, 8.0, 3.5, 2.0, 7.0, 1.0, 4.3, 7.2, 6.0, 8.5,
                     4.1, 5.0, 7.3, 2.8, 1.6, 8.9, 9.5, 3.2};
  float  z1ray[N] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
  float  z2ray[N] = {4.0, 5.0, 3.0, 2.0, 3.5, 4.5, 2.0, 1.6, 3.8, 4.7,
                     2.1, 3.5, 1.9, 4.2, 4.9, 2.8, 3.6, 4.3};
  int icray[N]    = {30, 30, 30, 30, 30, 30, 100, 100, 100, 100,
                     100, 100, 170, 170, 170, 170, 170, 170};

  for (i = 0; i < N; i++)
  { xwray[i] = (float) 0.5;
    ywray[i] = (float) 0.5;
  } 

  setpag ("da4p");
  metafl ("cons");
  disini ();
  pagera ();
  hwfont ();
  axspos (200, 2600);
  axslen (1800, 1800);

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

  titlin ("3-D Bars / BARS3D", 3);
  labl3d ("hori");

  graf3d (0.0, 10.0, 0.0, 2.0, 0.0, 10.0, 0.0, 2.0,
            0.0, 5.0, 0.0, 1.0);
  grid3d (1, 1, "bottom");
  bars3d (xray, yray, z1ray, z2ray, xwray, ywray, icray, N);

  legini (cbuf, 3, 20);
  legtit (" ");
  legpos (1350, 1150);
  leglin (cbuf, "First", 1);
  leglin (cbuf, "Second", 2);
  leglin (cbuf, "Third", 3);
  legend (cbuf, 3);

  height (50);
  title  ();
  disfin ();
  return 0;
} 
} 

Shading Patterns / C

#include <stdio.h>
#include "dislin.h"

int main ()
{ int   ixp[4], iyp[4], nl, nx, nx0 = 335, ny0 = 350, ny, i, j, ii, k, iclr;
  int  ix[4] = {0, 300, 300, 0}, iy[4] = {0, 0, 400, 400};
  char *ctit = "Shading Patterns (AREAF)", cstr[80];

  metafl ("cons");
  disini ();
  pagera ();
  complx ();
  setvlt ("small");

  height (50);
  nl = nlmess (ctit);
  nx = (2970 - nl) / 2;
  messag (ctit, nx, 200);

  iclr = 0;
  for (i = 0; i < 3; i++)
  { ny = ny0 +i * 600;
    for (j = 0; j < 6; j++)
    { nx = nx0 + j * 400;
      ii = i * 6 + j;
      nl = intcha (ii, cstr);
      shdpat (ii);

      iclr = iclr % 16;
      iclr++;
      setclr (iclr);

      for (k = 0; k < 4; k++)
      { ixp[k] = ix[k] + nx;
        iyp[k] = iy[k] + ny;
      }
      areaf  (ixp, iyp, 4);

      nl  = nlmess (cstr);
      nx += (300 - nl) / 2;
      messag (cstr, nx, ny + 460);
    }
  }
  disfin ();
  return 0;
}


3-D Colour Plot / C

#include <stdio.h>
#include <math.h>
#include "dislin.h"

float zmat[100][100];

int main ()
{ int n = 100, i, j;
  double   fpi = 3.1415927 / 180.0, step, x, y;

  step = 360.0 / (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));
    }
  }

  metafl ("cons");
  disini ();
  pagera ();
  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.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0,
            -2.0, 2.0, -2.0, 1.0);
  crvmat ((float *) zmat, n, n, 1, 1);
  
  height (50);
  title  ();
  disfin ();
  return 0;
}


Surface Plot / C

#include <stdio.h>
#include <math.h>
#include "dislin.h"

float zmat[50][50];

int main ()
{ int n = 50 ,i, j;
  double fpi = 3.1415927 / 180.0, step, x, y;
  char *ctit1 = "Surface Plot (SURMAT)",
       *ctit2 = "F(X,Y) = 2*SIN(X)*SIN(Y)";

  step = 360.0 / (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));
    }
  }

  setpag ("da4p");
  metafl ("cons");
  disini ();
  pagera ();
  complx ();
  axspos (200, 2600);
  axslen (1800, 1800);

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

  titlin (ctit1, 2);
  titlin (ctit2, 4);

  view3d (-5.0, -5.0, 4.0, "abs");
  graf3d (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0,
            -3.0, 3.0, -3.0, 1.0);
  height (50);
  title  ();

  color  ("green");
  surmat ((float *) zmat, 50, 50, 1, 1);
  disfin ();
  return 0;
}


Shaded Surface Plot / C

#include <stdio.h>
#include <math.h>
#include "dislin.h"

float zmat[50][50], xray[50], yray[50];

int main ()
{ int n = 50 ,i, j;
  double fpi = 3.1415927 / 180.0, step, x, y;
  char *ctit1 = "Shaded Surface Plot",
       *ctit2 = "F(X,Y) = 2*SIN(X)*SIN(Y)";

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

  setpag ("da4p");
  metafl ("cons");
  disini ();
  pagera ();
  complx ();
  axspos (200, 2600);
  axslen (1800, 1800);

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

  titlin (ctit1, 2);
  titlin (ctit2, 4);

  view3d (-5.0, -5.0, 4.0, "abs");
  graf3d (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0,
            -3.0, 3.0, -3.0, 1.0);
  height (50);
  title  ();

  shdmod ("smooth", "surface"); 
  surshd (xray, n, yray, n, (float *) zmat);
  disfin ();
  return 0;
}


Contour Plot / C

#include <stdio.h>
#include <math.h>
#include "dislin.h"

float xray[50], yray[50], zmat[50][50];

int main ()
{ int n = 50, i, j;
  double  fpi = 3.14159 / 180.0, step, x, y;
  float   zlev;

  step = 360.0/ (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");
  metafl ("cons");
  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.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0);

  height (30);
  for (i = 0; i < 9; i++)
  { zlev = (float) (-2.0 + 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 ();
  return 0;
}

Shaded Contour Plot / C

#include <stdio.h>
#include <math.h>
#include "dislin.h"

float xray[50], yray[50], zmat[50][50];

int main ()
{ int n = 50, i, j;
  double step, x, y;
  float  zlev[12];

  step = 1.6 / (n - 1);
  for (i = 0; i < n; i++)
  { x = 0.0 + i * step;
    xray[i] = (float) x;
    for (j = 0; j < n; j++)
    { y = 0.0 + j * step;
      yray[j] = (float) y;
      zmat[i][j] = (float) ((x * x - 1.0) * (x * x - 1.0) + 
                   (y * y - 1.0) * (y * y - 1.0));
    }
  }

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

  mixalf ();
  titlin ("Shaded Contour Plot", 1);
  titlin ("F(X,Y) = (X[2$ - 1)[2$ + (Y[2$ - 1)[2$", 3);
  name   ("X-axis", "x");
  name   ("Y-axis", "y");

  shdmod ("poly", "contur");
  axspos (450, 2670);
  graf   (0.0, 1.6, 0.0, 0.2, 0.0, 1.6, 0.0, 0.2);

  for (i = 1; i <= 12; i++)
    zlev[12-i] = (float) (0.1 + (i - 1) * 0.1);

  conshd (xray, n, yray, n, (float *) zmat, zlev, 12);

  height (50);
  title  ();
  disfin ();
  return 0;
}


Shaded Surface / Contour Plot / C

#include <stdio.h>
#include <math.h>
#include "dislin.h"

float zmat[50][50], xray[50], yray[50], zlev[20];

int main ()
{ int n = 50 ,i, j, nlev = 20;
  double fpi = 3.1415927 / 180.0, step, x, y;
  char *ctit1 = "Shaded Surface / Contour Plot",
       *ctit2 = "F(X,Y) = 2*SIN(X)*SIN(Y)";

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

  scrmod ("revers");
  setpag ("da4p");
  metafl ("cons");
  disini ();
  pagera ();
  hwfont ();
  axspos (200, 2600);
  axslen (1800, 1800);

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

  titlin (ctit1, 2);
  titlin (ctit2, 4);

  graf3d (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0,
            -2.0, 2.0, -2.0, 1.0);
  height (50);
  title  ();

  grfini (-1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0);
  nograf ();
  graf   (0.0, 360.0, 0.0, 90.0, 0.0, 360.0, 0.0, 90.0);
  step = 4.0 / nlev;
  for (i = 0; i < nlev; i++)
    zlev[i] = (float) (-2.0 + i * step); 

  conshd (xray, n, yray, n, (double *) zmat, zlev, nlev);
  box2d  ();
  reset  ("nograf");
  grffin ();

  shdmod ("smooth", "surface"); 
  surshd (xray, n, yray, n, (float *) zmat);
  disfin ();
  return 0;
}

Spheres and Tubes / C

#include <stdio.h>
#include "dislin.h"


int main ()
{ int i, j1, j2, iret;
  float  x[17] = {10.0, 20.0, 10.0, 20.0, 5.0, 15.0, 25.0, 5.0, 15.0, 25.0, 
                  5.0, 15.0, 25.0, 10.0, 20.0, 10.0, 20.0};
  float  y[17] = {10.0, 10.0, 20.0, 20.0, 5.0, 5.0, 5.0, 15.0, 15.0, 15.0,
                  25.0, 25.0, 25.0, 10.0, 10.0, 20.0, 20.0};
  float  z[17] = {5.0, 5.0, 5.0, 5.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0,
                  15.0, 15.0, 15.0, 25.0, 25.0, 25.0, 25.0};  
  int idx[]    = {1, 2, 1, 3, 3, 4, 2, 4, 5, 6, 6, 7, 8, 9, 9, 10,
                  11, 12, 12, 13,  5, 8, 8, 11, 6, 9, 9, 12, 7, 10,
                  10, 13,  14, 15, 16, 17, 14, 16, 15, 17,
                  1, 5, 2, 7, 3, 11, 4, 13, 5, 14, 7, 15, 11, 16, 13, 17};

  setpag ("da4p");
  scrmod ("revers");
  metafl ("cons");
  disini ();
  pagera ();
  hwfont ();
  light  ("on");
  matop3 (0.02, 0.02, 0.02, "specular");

  clip3d ("none");
  axspos (0, 2500);
  axslen (2100, 2100);

  htitle (50);
  titlin ("Spheres and Tubes", 4);

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

  labdig (-1, "xyz");  
  labl3d ("hori");
  graf3d (0.0, 30.0, 0.0, 5.0, 0.0, 30.0, 0.0, 5.0, 
            0.0, 30.0, 0.0, 5.0);
  title  ();

  shdmod ("smooth", "surface");
  
  iret = zbfini ();
  matop3 (1.0, 0.0, 0.0, "diffuse");
  for (i = 0; i < 17; i++)
    sphe3d (x[i], y[i], z[i], 2.0, 50, 25);

  matop3 (0.0, 1.0, 0.0, "diffuse");
  for (i = 0; i < 56; i += 2)  
  { j1 = idx[i] - 1;
    j2 = idx[i+1] - 1;
    tube3d (x[j1], y[j1], z[j1], x[j2], y[j2], z[j2], 0.5, 5, 5); 
  }

  zbffin ();
  disfin ();
  return 0;
}


Some Solids / C

#include <stdio.h>
#include "dislin.h"

int main ()
{ int iret;

  setpag ("da4p");
  scrmod ("revers");
  metafl ("cons");
  disini ();
  pagera ();
  hwfont ();
  light  ("on");
  litop3 (1, 0.5, 0.5, 0.5, "ambient");

  clip3d ("none");
  axspos (0, 2500);
  axslen (2100, 2100);

  htitle (60);
  titlin ("Some Solids", 4);

  nograf ();
  graf3d (-5.0, 5.0, -5.0, 2.0, -5.0, 5.0, -5.0, 2.0, 
            -5.0, 5.0, -5.0, 2.0);
  title  ();
 
  shdmod ("smooth", "surface"); 
  iret = zbfini ();

  matop3 (1.0, 0.5, 0.0, "diffuse");
  tube3d (-3.0, -3.0, 8.0, 2.0, 3.0, 5.5, 1.0, 40, 20); 

  rot3d (-60.0, 0.0, 0.0); 
  matop3 (1.0, 0.0, 1.0, "diffuse");
  setfce ("bottom");
  matop3 (1.0, 0.0, 0.0, "diffuse");
  cone3d (-3.0, -3.0, 3.5, 2.0, 3.0, 3.0, 40, 20);
  setfce ("top");

  rot3d (0.0, 0.0, 0.0); 
  matop3 (0.0, 1.0, 1.0, "diffuse");
  plat3d (4.0, 4.0, 3.0, 3.0, "icos");

  rot3d (0.0, 0.0, 0.0); 
  matop3 (1.0, 1.0, 0.0, "diffuse");
  sphe3d (0.0, 0.0, 0.0, 3.0, 40, 20);

  rot3d (0.0, 0.0, -20.0); 
  matop3 (0.0, 0.0, 1.0, "diffuse");
  quad3d (-4.0, -4.0, -3.0, 3.0, 3.0, 3.0);

  rot3d (0.0, 0.0, 30.0); 
  matop3 (1.0, 0.3, 0.3, "diffuse");
  pyra3d (-2.0, -5.0, -10.0, 3.0, 5.0, 5.0, 4);

  rot3d (0.0, 0.0, 0.0); 
  matop3 (1.0, 0.0, 0.0, "diffuse");
  torus3d (7.0, -3.0, -2.0, 1.5, 3.5, 1.5, 0.0, 360.0, 40, 20);
  rot3d (0.0, 90.0, 0.0); 

  matop3 (0.0, 1.0, 0.0, "diffuse");
  torus3d (7.0, -5.0, -2.0, 1.5, 3.5, 1.5, 0.0, 360.0, 40, 20);
  zbffin ();
  disfin ();
  return 0;
}


Map Plot / C

#include <stdio.h>
#include "dislin.h"

int main ()
{
  metafl ("cons");
  disini ();
  pagera ();
  complx ();

  frame  (3);
  axspos (400, 1850);
  axslen (2400, 1400);

  name   ("Longitude", "x");
  name   ("Latitude", "y");
  titlin ("World Coastlines and Lakes", 3);

  labels ("map", "xy");
  grafmp (-180.0, 180.0, -180.0, 90.0, -90.0, 90.0, -90.0, 30.0);

  gridmp (1, 1);
  color  ("green");
  world  ();
  color  ("fore");

  height (50);
  title  ();
  disfin ();
  return 0;
}


TeX Instructions for Mathematical Formulas / C

#include <stdio.h>
#include "dislin.h"

int main ()
{ char cstr[80] = "TeX Instructions for Mathematical Formulas";
  int nl;
  
  setpag ("da4p");
  metafl ("cons");
  disini ();
  pagera ();
  complx ();
  height (40);

  nl = nlmess (cstr);
  messag (cstr, (2100 - nl)/2, 100);
  
  texmod ("on");
  messag ("$\\frac{1}{x+y}$", 150, 400);
  messag ("$\\frac{a^2 - b^2}{a+b} = a - b$", 1200, 400);
  
  messag ("$r = \\sqrt{x^2 + y^2}", 150, 700);
  messag ("$\\cos \\phi = \\frac{x}{\\sqrt{x^2 + y^2}}$", 1200, 700);

  messag ("$\\Gamma(x) = \\int_0^\\infty e^{-t}t^{x-1}dt$", 150, 1000);
  messag ("$\\lim_{x \\to \\infty} (1 + \\frac{1}{x})^x = e$", 1200, 1000);

  messag ("$\\mu = \\sum_{i=1}^n x_i p_i$", 150, 1300);
  messag ("$\\mu = \\int_{-\\infty}^ \\infty x f(x) dx$", 1200, 1300);

  messag ("$\\overline{x} = \\frac{1}{n} \\sum_{i=1}^n x_i$", 150, 1600);
  messag ("$s^2 = \\frac{1}{n-1} \\sum_{i=1}^n (x_i - \\overline{x})^2$",
          1200, 1600);

  messag ("$\\sqrt[n]{\\frac{x^n - y^n}{1 + u^{2n}}}$", 150, 1900);  
  messag ("$\\sqrt[3]{-q + \\sqrt{q^2 + p^3}}$", 1200, 1900);

  messag ("$\\int \\frac{dx}{1+x^2} = \\arctan x + C$", 150, 2200);
  messag ("$\\int \\frac{dx}{\\sqrt{1+x^2}} = {\\rm arsinh} x + C$",
          1200, 2200);

  messag ("$\\overline{P_1P_2} = \\sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}$",
           150,2500);
  messag ("$x = \\frac{x_1 + \\lambda x_2}{1 + \\lambda}$", 1200, 2500);
  disfin ();
  return 0;
}  
Zur Redakteursansicht