You are on page 1of 4



Math for game programmers 01 Introduction | Higher-Order Fun


Higher-Order Fun
Game Design & Game Programming

Math for game programmers 01 Introduction

Here comes a harsh fact of life: game programming requires mathematics. One could say that programming IS, in a way, math, but you dont really need to know math to write the vast majority of programs. Most of the time, you dont need it to write parsers, to interact with databases, to validate data. Games, however, very often rely on mathematics. If you want objects to move across your world realistically, or if you want to draw things on the screen following certain geometric patterns, or if you want to check for collision between certain shapes, you need math. But dont despair! Even though I say math, what you ACTUALLY need is geometry. Luckily for us, geometry is probably the easiest part of mathematics! Now, Im not saying that discrete mathematics, algebra and calculus are useless for writing games (or other sorts of programs), but geometry is the bread and butter of video game programmers. An interesting thing that I did notice is that, despite my previous assertion, many game programmers do not actually know much geometry! This means that theyll often do things in extremely laborious, buggy and verbose ways, when it could very easily be done with some basic grasp of geometry. For example, if you want to place several objects along an arc of circle, you COULD do it through trial and error, or place it in an image editing program (like Photoshop) and copying the coordinates, but it will be much easier if you simply use a parametric equation. So I intend to write a few posts to explain, as clearly as I can, some topics that are important to game programming. These are the topics that I intend to cover: Vectors Parametric Equations Vector bases Basic Trigonometry Matrices Complex Numbers Quaternions While there are many basic and in-depth tutorials of all of the above topics on the Internet, explanations as to why the matter to game programmers and how to use them seem to be scarce, or left as an exercise to the reader. My goal is to make those topics easy to understand and put into use.


I'm Rodrigo Monteiro, and I have been programming video games since 1997, ranging from Klik & Play to C++ and Java. I'm the creator of the Aegisub subtitling software (together with Niels Hansen), and I like joining game programming challenges such as the Allegro SpeedHack and the Global Game Jam. I currently work as a professional video game programmer at Bossa Studios, in London, United Kingdom. All opinions are my own. More...

September 2012 (1) June 2012 (1) May 2012 (2) February 2012 (1) November 2011 (1) September 2011 (1) June 2011 (1) May 2011 (1) February 2011 (3) August 2010 (1) February 2010 (1) June 2009 (4)

by a m z / Ju n e 7 , 2 0 0 9 / Post ed in : m a t h , t u t or ia l T a g g ed: m a t h , t u t or ia l

20 Com m en t s

P re v io u s p o s t

Next po s t

main = putStrLn "Hello world!"

Math for game programmers 02 Vectors 101


20 Responses
Kenneth Blok

Leave one

article c++ dia blo dow n g oes t h e ph oen ix ex per im en t g a m e game design g a m e ja m
g r een lig h t h u m or lect u r e m a in loop

/ 2 0 1 2 -0 9 -0 3

I bought Mathematics for 3D Programming and computer graphics 3rd Edition by Langyel, which I consider an absolute must if you want to understand what you are doing.

math open g l ph oen ix pr esen t a t ion programming rant religion

spja m st ea m t ech n ica l t h r ea d



Math for game programmers 01 Introduction | Higher-Order Fun

It gave me a good base for reading the OpenGL Superbible 5th Edition by Writght, Haemel, Sellers and Lipchak.

w in 3 2

v ect or

vectors v ideo

Ajay Parmar
Great!! I am waiting..

/ 2 0 1 2 -0 9 -0 3

Aegisub Blog

Ben Dover

/ 2 0 1 2 -0 9 -0 3

The best way to learn the topics mentioned here is to attend high school.

Phil Mc Cafferty

/ 2 0 1 2 -0 9 -0 3

Follow me @amzeratul

and study french of course, as everyone knows the french are the best mathematicians.

P. B. Moss

/ 2 0 1 2 -0 9 -0 3

Quite clearly whoever wrote the last two posts certainly attended high school as they still posess the pathetic schoolboy humour. Grow up and get a life! This could be a very interesting series and I look forward to it.


/ 2 0 1 2 -0 9 -0 3

Im a mathematician and the mentioned topics are a piece of cake for me. Dont need to waste my time on those. Better learn more programming, that cant be enough for me since this is not my speciality.


/ 2 0 1 2 -0 9 -0 3

And geometry is not the easiest part of math, trust me. While in algebra you can solve problems using more or less defined approaches, solving geometrical problems requires way more imagination and creativity. Nevertheless, I agree that the geometrical facts themselves are easier to understand since they dont require as many sophisticated formulas as algebra. From this point of view, you are right.

Mike Hanson

/ 2 0 1 2 -0 9 -0 3

You need a lot more than that. Reflection of objects on shiny surfaces such as mirrors, effects of gravity on objects, perspective in 3D games, develop sound effects to enhance image. These are just a few things to consider. I did get my start with geometry writing 2D games.


/ 2 0 1 2 -0 9 -0 3

As an engineer, I caught myself using geometry to solve many problems on development from very simple games, to factory software. Its amazing how one problem can become very difficult when you dont know the math. Its like riding a mountain bike uphill without realizing it has gears to help you with that. What I dont agree with you is that to me geometry is one of the hardest part of mathematics, it requires a lot of imagining (which I am not good at) so you can apply geometry correctly should I use sin or cosing? This can entangle the brain sometimes and usually leads to some trial and error in my case. Now, calculus and statistics to me are much easier, it usually requires just to identify a problem and pick the right equation for the job.



Math for game programmers 01 Introduction | Higher-Order Fun


/ 2 0 1 2 -0 9 -0 4

Awesome! You have been bookmarked my friend


/ 2 0 1 2 -0 9 -0 4

Bookmarked, got a huge interest in math and programming, my degree is math, and application of math concepts in an application always fascinates me


/ 2 0 1 2 -0 9 -0 4

Great, Got a huge interest in math and programming, my degree is math, and application of math concepts in an application is exciting. Any physics write ups coming soon, I hear its important in games prog.?


/ 2 0 1 2 -0 9 -0 4

Exciting! Looking forward to your posts!


/ 2 0 1 2 -0 9 -0 5

nice , i also love maths and computer programming . it is interesting for me too

Ben -

/ 2 0 1 2 -0 9 -0 5

And the best way for you to learn anything is to pull your head out of your *SS. Rodrigo Looking forward to your posts.


/ 2 0 1 3 -0 1 -1 7

Thanks for the article ! I cant wait to read the one about the matrices.

great article!!

/ 2 0 1 3 -0 2 -1 7

im korean programmer , i read your article to translate korean language thx

1. Math for Game Programmers 05 Vector Cheat Sheet | Higher-Order Fun 2. Matematika (pontosabban geometria) jtkprogramozknak MolePlex 3. .NET i jin ... : Odkazy z prohlee 7.9.2012

Leave a Reply
Name *

E-mail *



Math for game programmers 01 Introduction | Higher-Order Fun


Submit Comment