#include "Swarming.H" /************************************************************************* * This subroutine draw the axis for the graph while adjusting * the grid tics and labels. ************************************************************************/ void gtDrawAxis(double xlo, double xhi, double ulo, double uhi) { double xcenter=(0.0-xlo)/(xhi-xlo); double ycenter=(0.0-ulo)/(uhi-ulo); glBegin(GL_LINES); glVertex2f(1,ycenter); glVertex2f(0,ycenter); glVertex2f(xcenter,0); glVertex2f(xcenter,1); glEnd(); double len=uhi-ulo; float interval=pow(10., (double)((int)log10(len))); for(int tic=1; interval*(float)tic<=uhi; tic++) { float y_pos=ycenter+interval*(float)tic/(float)len; char label[10]; glBegin(GL_LINES); glVertex2f(xcenter,y_pos); glVertex2f(xcenter+0.05,y_pos); glEnd(); glRasterPos2f(xcenter+0.06,y_pos-0.025); sprintf(label, "%3.1f", interval*(float)tic); int len=(int)strlen(label); for(int il=0; il=ulo; tic--) { float y_pos=ycenter+interval*(float)tic/(float)len; char label[10]; glBegin(GL_LINES); glVertex2f(xcenter,y_pos); glVertex2f(xcenter+0.05,y_pos); glEnd(); glRasterPos2f(xcenter+0.06,y_pos-0.025); sprintf(label, "%3.1f", interval*(float)tic); int len=(int)strlen(label); for(int il=0; il=xlo; tic--) { float x_pos=xcenter+interval*(float)tic/(float)len; char label[10]; glBegin(GL_LINES); glVertex2f(x_pos,ycenter); glVertex2f(x_pos,ycenter+0.05); glEnd(); glRasterPos2f(x_pos-0.05,ycenter+0.06); sprintf(label, "%3.1f", interval*(float)tic); int len=(int)strlen(label); for(int il=0; il