POLTEST.C
/****************************************************************************
(c) 1984 - 2003 by Scientific Endeavors Corporation.
All rights reserved.
This program draws two polar plots.
****************************************************************************/
#include <graphic.h> /* Include all needed files */
#if TCQ /* Set stack for Borland (Turbo) C */
extern unsigned _stklen = 0x3000;
#endif
float e[241];
float th[241];
static char *larray[ ] = {"-20db", "0db", "+20db"};
/****************************************************************************
Main program
****************************************************************************/
void GPC_MAIN(void)
{
int i;
char col = 0;
int mode = 0;
float rmax,rmin;
double theta;
rmax = 40.f; /* Generate data points */
rmin = -20.f;
e[0] = e[240] = 0.f;
th[0] = th[240] = 0.f;
for(i = 1; i < 240; i++){
theta = (double)i * PI / 120.f;
e[i] = (float)(15. + 20. * log10(fabs(
sin(2. * PI * (1. - cos(theta))) / (tan(theta * .5)))));
th[i] = (float)theta;
}
bgnplot(1, 'g', "pol.tkf"); /* GraphiC initialization */
startplot(WHITE);
metricunits(0); /* Ensure scaling in inch units */
font(3, "simplex.fnt", '\310', "triplex.fnt", '\311', /* Select fonts */
"complex.fnt", '\312');
page(9.0f, 6.884f); /* Size of page and plot area */
area2d(8.0f, 6.0f);
color(MAGENTA); /* Magenta box around plot */
box();
color(BLUE); /* Blue heading */
heading("\311Antenna Pattern - db");
color(BROWN); /* Brown polar grid */
fntchg((Uchar)'\310');
polgrid(rmax, rmin, mode, larray, 3, 8, col);
color(BLUE); /* Blue curve with symbols */
sympick(1);
polcurve(e, th, 241, 10);
dateit((Uchar)'\312'); /* Put date-time stamp on plot */
if (endplot()) /* Terminate 1st plot */
goto EndOfApp;
startplot(WHITE); /* Initialize 2nd plot */
page(9.0f, 6.884f); /* Size of page and plot area */
area2d(8.0f, 6.0f);
color(MAGENTA); /* Magenta box around plot */
box();
for(i = 1; i < 240; i++){ /* Generate data points */
theta = th[i];
e[i] = (float)(fabs(
sin(2. * PI * (1. - cos(theta))) / (tan(theta * .5))));
}
mode = 1; /* Log grid */
rmax = 3.f;
rmin = 0.f;
larray[0] = "1.0"; /* Axis labels */
larray[1] = "2.0";
color(BLUE); /* Blue heading */
heading("\311Antenna Pattern - abs. field");
color(BROWN); /* Brown polar grid */
fntchg((Uchar)'\310');
polgrid(rmax, rmin, mode, larray, 2, 12, col);
color(BLUE); /* Blue curve with symbols */
polcurve(e, th, 241, 10);
dateit((Uchar)'\312'); /* Put date-time stamp on plot */
endplot(); /* GraphiC closing routines */
EndOfApp:
stopplot();
}