Quote:Professor Charles Anthony Richard Hoare: Premature optimization is the root of all evil. |
Quote:Attributed to Kent Beck: Make it work. Make it right. Make it fast. |
Quote:Source unknown (paraphrased): 90% of execution time is spent in 10% of the code. |
I believe your original code should be something like:
void positionWorld(){ glRotatef(pitch,1.0f,0,0); glRotatef(heading,0,1.0f,0); /* Almost certainly an unnesseccary test and an example of premature optimisation if ((velocity > 0) || (velocity < 0)) {*/ float cosPitch = std::cos(pitch * piover180); xpos += sin(heading * piover180) * velocity * cosPitch; zpos -= cos(heading * piover180) * velocity * cosPitch; ypos -= sin(pitch * piover180) * velocity;/* }*/ glTranslatef(-xpos, -ypos, -zpos);}
Enigma