/* >>>>>>>>>> EXA_2 <<<<<<<<<< */ void exa_2 (void) { int n = 300, m = 10, i; double f = 3.1415926 / 180., step, a; float 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"); 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); grafp (1.f ,0.f, 0.2f, 0.f, 30.f); curve (xray, yray, n); htitle (50); title (); endgrf (); labdig (-1, "X"); axsorg (1050, 2250); labtyp ("VERT", "Y"); grafp (10.f, 0.f, 2.f, 0.f, 30.f); barwth (-5.f); polcrv ("FBARS"); curve (x2, y2, m); disfin (); }
/* >>>>>>>>>> EXA_4 <<<<<<<<<< */ void exa_4 (void) { int nya, i; static char ctit[] = "Logarithmic Scaling", cstr[60], *clab[3] = {"LOG", "FLOAT", "ELOG"}; setpag ("da4p"); disini (); pagera (); hwfont (); axslen (1400, 500); name ("X-axis", "x"); name ("Y-axis", "y"); axsscl ("log", "xy"); titlin (ctit, 2); for (i = 1; i <= 3; i++) { nya = 2650 - (i - 1) * 800; labdig (-1, "xy"); if (i == 2) { labdig (1, "y"); name (" ", "x"); } axspos (500, nya); color ("yellow"); strcpy (cstr, "Labels: "); strcat (cstr, clab[i-1]); messag (cstr,600,nya-400); color ("fore"); labels (clab[i-1],"xy"); graf (0.f, 3.f, 0.f, 1.f, -1.f, 2.f, -1.f, 1.f); if (i == 3) { height (50); title (); } endgrf (); } disfin (); }
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; }
/* >>>>>>>>>> EXA_7 <<<<<<<<<< */ void exa_7 (void) { int n = 100, i, nx, ny; double fpi = 3.1415926/180., step, x; char cbuf[20]; 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); } disini (); hwfont (); pagera (); axspos (450, 1800); axslen (2200, 1200); name ("X-axis", "x"); name ("Y-axis", "y"); labdig (-1, "x"); ticks (10, "xy"); titlin ("Demonstration of Curve", 1); titlin ("Legend", 3); graf (0.f, 360.f, 0.f, 90.f, -1.f, 1.f, -1.f, 0.5f); title (); xaxgit (); chncrv ("both"); curve (xray, y1ray, n); curve (xray, y2ray, n); legini (cbuf, 2, 7); nx = nxposn (190.f); ny = nyposn (0.75f); legpos (nx, ny); leglin (cbuf, "sin (x)", 1); leglin (cbuf, "cos (x)", 2); legtit ("Legend"); legend (cbuf, 3); disfin (); }
/* >>>>>>>>>> EXA_12 <<<<<<<<<< */ void exa_12 (void) { int i, nxp, nyp; float xp, yp; static float xc[9] = {-22.f,18.f,37.5f,0.f,2.5f,12.5f,23.5f,-3.75f,14.25f}, yc[9] = {64.f,59.6f,56.f,51.5f,48.5f,42.f,38.f,40.3f,50.1f}; static char *cstr[9] = {"REYKJAVIK", "STOCKHOLM", "MOSKAU", "LONDON", "PARIS", "ROM", "ATHEN", "MADRID", "PRAG"}; disini (); pagera (); hwfont (); axspos (500, 1850); axslen (2200, 1400); labdig (-1, "xy"); ticks (1, "xy"); name ("Longitude", "x"); name ("Latitude", "y"); titlin ("Map Plot", 3); incmrk (-1); labels ("map", "xy"); projct ("lambert"); frame (3); grafmp (-40.f, 60.f, -40.f, 20.f, 35.f, 70.f, 40.f, 10.f); color ("green"); world (); color ("fore"); curvmp (xc, yc, 9); for (i = 0; i < 9; i++) { pos2pt (xc[i], yc[i], &xp, &yp); nxp = (int) (xp + 30); nyp = (int) yp; messag (cstr[i], nxp, nyp); } gridmp (1, 1); height (50); title (); disfin (); }
/* >>>>>>>>>> EXA_1 <<<<<<<<<< */ void exa_1 (void) { int n = 100, i; double fpi = 3.1415926 / 180., step, x; 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); } disini (); pagera (); hwfont (); axspos (450, 1800); axslen (2200, 1200); name ("X-axis", "x"); name ("Y-axis", "y"); labdig (-1, "x"); ticks (10, "xy"); titlin ("Demonstration of CURVE", 1); titlin ("SIN(X), COS(X)", 3); graf (0.f, 360.f, 0.f, 90.f, -1.f, 1.f, -1.f, 0.5f); title (); color ("red"); curve (xray, y1ray, n); color ("green"); curve (xray, y2ray, n); color ("fore"); dash (); xaxgit (); disfin (); }