next up previous
Next: reshape Up: Code Previous: Initialization

Helper Functions

The functions are defined early in the code and then used throughout the rest of the program to make the code later simpler and mor organized.
double abs(double x)	// returns the absolute value of the integer entered
{
	if(x<0)
		return (x*-1);
	return x;
}

int pow(int base, int exp)	// returns base ^ exp
{
	if(!exp)
		return 1;
	return base*pow(base, exp-1);
}

void rotx(int num)
{
	glRotatef(num, 1.0, 0.0, 0.0);
}

abs returns the absolute value of the integer sent to it. pow returns, recursively, the value of base raised to the exp power. rotx, in openGL, rotates the current matrix num degrees around the x axis of the picture. this only saves space in the code, not lines, and makes the calls easier to create.



Michael Hull 2003-06-11