## Math for game development

25 Dec

For those who don’t know, you can read my new series on the mathematics used in game development at www.fromatogra.com.

Rather than giving you only code and a vague explanation, the series tries to explain the fundamentals behind it, making it easier to remember as well as really understand what is happening.

It tries to teach you to fish, rather than giving you a fish.

The idea came to me as I saw how many game developers struggle with mathematical concepts. It’s not their fault, but rather the abstract and boring way that mathematics is often thaught at both school and university level. If you only have a very vague idea of a certain tool, you might not think of the tool as a solution for your problem.

The result though is that a lot of software, be it games, browsers or graphics layers are slower than they should be. And that some game developers can’t create their vision as they don’t know how.

I hope that for some, this series will be a way to jump-start their interest in understanding rather than mere using mathematics.

While I’m always writing a few chapters ahead, I also revisit older chapters now and then to add content or refine explanations. I usually notify about these changes using Twitter.

9 Sep

This might save some people from losing a few hours over a seemingly simple issue. When you update the Google Play Services SDK, and possibly the Android API, it might happen that your application suddenly crashes when calling isGooglePlayServicesAvailable with a NoClassDefFoundError.

17 Aug

Although HTTPS is the default protocol to secure websites and web services, it seems that it is often badly understood. These are two points which often crop up in forums.

18 May

# Drop the last column

A 2D transform is typically shown as a 3×3 augmented matrix. However the last column (or row depending which order you use) of an augmented matrix is always 0 0 1, so we don’t need to store it. We only store a 2×3 matrix.

$\begin{bmatrix} a & b \\ c & d \\ e & f \end{bmatrix}$

The 2 upper rows will contain the rotation, scale and shear factors, while the lower row contains the translation.

## Using the NDK and JNI to build android applications

25 Aug

When writing applications for android in java, there are often parts that you expected to perform better. It’s not always the algorithm that is to blame. Java has its limits. Even with a JIT compiler it will have more runtime overhead, and a garbage collector will run at times you don’t want it to. We can solve this by moving demanding pieces of our code to C, C++ or assembler.  Continue reading

## Optimization tip: reduce the amount of code to execute

21 Jul

Reducing the amount of code to execute is not always the work of the compiler, the person writing the code has to be conscious of how the code will end up in instructions in order to obtain optimized binary code.

## Optimization tip: don’t use sqrt when comparing distances

7 Jul

When comparing distances, whether it be for collision detection in games or drawing circles or discs (like in this recent Geeks3D post) I often see people using sqrt when they are comparing distances. This sqrt is not needed and only wastes CPU or GPU time.