Dynamic Biorhythm Graphs
Gnuplot And Ppmtogif Bring Your Web-Based Graphs
By Andrew Davison
Many Web applications require the dynamic generation of images in response to user input. Applications can dynamically draw images containing graphic primitives such as lines, circles, and polygons using the functions in Thomas Boutell's gd graphics library (www.boutell.com/gd/). But what if you want to generate graphs based on equations or tables of data? The most common approach is to combine two freely available packages, gnuplot and pbmplus, to plot the data and transform it into a GIF.
To illustrate, I'll present pb.c, an application that transforms graphs generated by the gnuplot utility into GIF files with the ppmtogif utility, and allows users to dynamically display various parts of the graphs.
Biorhythms
The graphs I'll use in pb.c depict the equations for the sine waves that constitute a biorhythm.
A "biorhythm" comprises three sine waves of different frequencies that supposedly control our physical, emotional, and intellectual fluctuations. The physical wave repeats every 23 days and controls vitality and endurance; the emotional wave repeats every 28 days and controls temperament and sensitivity; the intellectual wave repeats every 33 days and controls thinking capacity. A wave value above 0 is considered auspicious; when it falls below 0, beware. To calculate the sine waves for a given month, a user typically supplies his or her date of birth (when the waves began) and a month of interest.<>