CNTTEST.C
/****************************************************************************
(c) 1984 - 2003 by Scientific Endeavors Corporation.
All rights reserved.
This program draws a contour plot.
****************************************************************************/
#include <graphic.h> /* Include all needed files */
#if TCQ /* Set stack for Borland (Turbo) C */
extern unsigned _stklen = 0x3000;
#endif
int lnstyle[ ] = { /* Colors and line styles */
251, 242, 233, 224, 215, 206, 191, 252, 243, 232, 223, 214, 201,
192, 253, 244, 231, 222, 213, 204, 191, 112, 123, 134, 151
};
float W_CDECL fun(float x, float y);
/****************************************************************************
Main program
****************************************************************************/
void GPC_MAIN(void)
{
float x[65], y[85];
float pi = (float)PI;
float zorig = -1.f, zstep = .1f, zmax = 1.f;
float pix = pi / 64.f, piy = pi / 42.f;
int i, nx = 65, ny = 85, labint = 2;
for(i = 0; i < nx; i++) /* Generate data points */
x[i] = pix * (float)i;
for(i = 0; i < ny; i++)
y[i] = piy * (float)i;
bgnplot(1, 'g', "cnt.tkf"); /* GraphiC initialization */
startplot(BLACK);
metricunits(0); /* Ensure scaling in inch units */
font(3, "simplex.fnt", '\310', "triplex.fnt", '\311', /* Select fonts */
"microb.fnt", '\312');
rotate(1); /* Plot rotated 90 degrees */
page(6.884f, 9.0f); /* Size of page and plot area */
area2d(5.8f, 7.3f);
color(WHITE); /* White box around plot */
pbox();
xname("\310x"); /* Axis and plot titles */
yname("\310y");
heading("\312sin(y)*cos(x-y)");
graf("%-4.4f", 0.0f, pi * .5f, pi, "%-4.4f", 0.f, pi * .5f, 2.f * pi);
color(BLUE); /* Draw contour plot */
contour(fun, (float *)x, nx, (float *)y, ny, zorig, zstep, zmax,
(int *)lnstyle, labint);
color(BLUE);
endplot(); /* GraphiC closing routines */
stopplot();
}
/****************************************************************************
Definition of function to be plotted.
****************************************************************************/
float W_CDECL fun(float x, float y)
{
return((float)(sin((double)y) * cos((double)(x - y))));
}