🧮 How To Write Fast Game Engine Math
Text Version
-
Are you in a linear space?
-
YES:
- Congratulations, things are easy and fast!
- Task Complete.
-
No:
- GOTO 2.
-
YES:
-
Can you easily get into one?
-
YES:
- GOTO 1.
-
NO:
- GOTO 3.
-
YES:
-
Can you pretend the space is linear?
-
YES:
- GOTO 1.
-
NO:
- Zoom in on the graph.
- GOTO 3.
-
YES:
Following these steps results in apparent black magic such as replacing inverse square roots with -0.5*x + 1.5, or replacing the quaternion log/exponent with truncation/extension of the imaginary component.
I’ve been taking this approach while working on my math libraries mr_tween and mr_geom over the past few days so that I can add a damped spring transform to my game. This sort of math typically takes me a while, but understanding how things actually work always seems to pay off in the long run.