TRITEST.C

/*Triangle plots provide for the graphic display of an attribute of a
three-component mixture. Each component is associated with a vertex. The
fraction of that component is plotted on a line parallel to the opposite
side. The position of the line is proportionally closer to the vertex
depending on the relative amount of the component. Any two components
determine the position of a point. GraphiC draws constant-value contours of
the attribute. */

#include <graphic.h>            /* Includes all the necessary header 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 a,float b);        /* Definition of function to be plotted */
void GPC_MAIN(void)
{
    float zmin,zstep,zmax;
    unsigned dim;

    dim=49;
    zmin=48.f;
    zstep=2.f;
    zmax=60.f;
    bgnplot(1,'g', "tri.tkf");                          /* Initialize plot */
    startplot(BLACK);                                  /* Black background */
    metricunits(0);                        /* Ensure scaling in inch units */
    font(2,"simplex.fnt",'\310',"microb.fnt",'\311');        /* Load fonts */
    page(9.0f,6.884f);                                  /* Page dimensions */
    area2d(7.0f,5.5f);                             /* x and y axis lengths */
    color(WHITE);
    pbox();                                  /* Draw a box around the plot */
    heading("\311Triangle Test");                            /* Plot title */
    aname("\310A-Scale");                     /* Names for the three sides */
    bname("B-Scale");
    cname("C-Scale");
    trifun(fun, dim, zmin, zstep, zmax, (int *)lnstyle, 14);   /* Contours */
    endplot();                              /* Get beep and wait for input */
    stopplot();                          /* Terminate plot and close files */
}

/*********************************************************************

 Definition of function to be plotted

*********************************************************************/

float W_CDECL fun(float a, float b)
{
    float c;

    c = 1 - a - b;
    return(47 * a + 49 * b + 53 * c + 32 * b * c + 20 * a * c +
        (float)123.02 * a * b * c);
}