## Fast Game Mathematics

As for myself, I never had anything to do with game programming. I’m a normal J2EE Developer / Architect in my “real” life, working for a big IT-Company here in Germany. If you are entering game programming you have to learn to throw some common java habits overboard. Besides the “Aiming for Performance” Arcticle ” down below, there are some more technical issues that can speed up your game. A good starting point is a wiki article about fast square roots (Link). The thing with the square roots is especially interesting if you are going 3D.

Another aspect is the Math factor.

int result = inputInt / 2; int result2 = inputInt >> 1;

If you have some division by the power of 2, then you can simple shift the bits. In my TestCase this is like 8x faster than the standard division. Another useful approach are Data Tables, when you don’t need exact values. If you are calculating angles with Math.tan() or something similar, you might want to consider to pre calculate the angles your need for your game. In my case the rotation of arrows in 10 degree steps. So the only thing you have to to is to divide the cathetus and search for a Number in the table. In my case 5x times faster that Java Math.

Thanks I was wondering about using shift. Your other performance article had good tips too.

Hey did you ever implement the fast square root for Java?

Ah nevermind, I found an implementation for invSqrt():

http://www.sawp.com.br/blog/?p=305

Unfortunately, the tests show it’s just as fast as 1.0f / sqrt() 🙁

I wonder if that’s still true in Android….

Hi UA, depends on how you test it. On your “local” Computer there may not be a big difference, because the CPU can handle those big floating point stuff better than the CPU on Android. If you are interested I can send you my implementation of square root based on a static table.

Definitely believe that which you said. Your favorite justification appeared to be

on the net the simplest thing to be aware of. I say to you, I certainly

get annoyed while people think about worries that they plainly do not know about.

You managed to hit the nail upon the top and also defined out

the whole thing without having side-effects , people could take a signal.

Will probably be back to get more. Thanks

What’s up mates, how is the whole thing, and what you would like to say on the topic

of this paragraph, in my view its genuinely awesome in support of me.

WOW just what I waas looking for. Came here by searching for rencontrer

des gens sur paris