How much math and physics do you have to know for game programming?

Started by DragonmasterX, August 25, 2012, 06:30:32 AM

Previous topic - Next topic

DragonmasterX

It seems to me like most universities make physics and calculus mandatory courses for computer science degrees...

But specifically in game programming, how much of that stuff do you really need? Isn't high school level algebra enough? How high level does the physics get? I'm guessing that comes more into play for 3D games? Is all this stuff irrelevant in romhacking? Perhaps even less so for social games?

I gave up programming in college because I wasn't so great at it, and I was getting 100s on Japanese exams without studying, so I changed my major to East Asian Studies. So ultimately, how much math/physics is REALLY necessary in actual game programming  is something I've always wondered.

LostTemplar

With anything related to programming you're going to need math to a certain degree.

I'm no game programming expert myself, but if you're doing 3D games you most certainly have to have at least a basic knowledge of linear algebra as taught in most first semester courses at university. This includes especially vectors & matrices and anything pertaining to them like vector spaces, scalar products, etc.

Calculus probably isn't that much needed for the 3D itself, but more for the physics used in a 3D (or even 2D) world. Most physical concepts like velocity or springs are based on derivatives, so it is mandatory to have an understanding of them, but I guess unless you're going to code a super-realistic physics engine, highschool physics & calculus might just be enough (though I can only judge by the stuff I learned in highschool resp. Gymnasium as it is called here).

If you're opting for 2D games the math problem is alleviated quite a bit, but I'd say highschool level math still is the minimum requirement. It of course all depends on the game, though. In ROM hacking, on the other hand, depending on what you want do achieve, math usually isn't that much of a problem. It's more about basics then, like different bases (2, 10, 16) or arithmetics.

henke37

You should understand how forces work and how polar coordinates work.

The real skills you need is being able to design programs. How to work with more than one object and such. Actual data structures aren't too important. It's not going to matter if you use a linked list or a hashtable, what matters in reality is if you can work with more than one object at a time.

Bregalad

Basically, what you learn in high scool is enough for game programming, exept if you want to code your own 3D engine where some basic linear algebra will be required but nothing too serious.

The only reason those annoying calculus and physics course are mandatory in universities is just to show off, and to make sure only the most intelligent people makes it to higher degrees.
I know what I'm talking about since I had to endure this until last year. Now it seems to me it was forever ago and I probably forgot 100% of the complex calculus I learned (not mathematically complex - I meant technically complex - By the way I use complex numbers in EE regularly, but it's just the basics, not the "technically complex" stuff). I'd be completely unable to pass the exams I passed the last couple of years ago again, how ironical. But since about 97% of other students are in the same case, I guess it's meant to be like this, and that this is "normal".

Back to the topics, the only mathematical needs are :
- Basic movement stuff, velocity, acceleration, etc...
- Trigonometry, how to do circles with sin/cos, etc...
- If you're programming a music engine, knownledge in exponentials and logarhtms will be required.
- If you're programming a 3D engine, knownledge about projection matrices, and vectors
- This is more computer science than math, but I can't stress how important is to know well how to count in binary/hex, and to use fixed point representations of numbers. Those are used everywhere in games.

LostTemplar

Quote from: Bregalad on August 25, 2012, 11:44:45 AM
The only reason those annoying calculus and physics course are mandatory in universities is just to show off, and to make sure only the most intelligent people makes it to higher degrees.

It's sad that you think that way.

Bregalad

Sad ? Those courses and their respective teachers for them really, really pissed me off back then.

Back then I shut up and forced my self to study those things even though I didn't gave it much interest, now that I have passed I can freely express my thoughts. I just say it this way to other students, and many of them seems to agree with me. In fact even some of my teachers probably feel the same.

However the new part for me is that this "problem" is not exclusive to my uni, but seems to be a worldwide standard. This raises another reason technically-complex calculus and physics is compulsory studying in unrelated faculties : This seems to be an international standard.

PS : Oh and don't get me wrong, back in high school, I loved math, and this was my favourite course. Nowadays, I deeply loathe calculus and physics, thanks to the uni and to a couple of particularly horrible teachers.

BRPXQZME

It all depends on what kind of game programming you do. There are many different kinds of game programming. It's not really a yes/no answer.
we are in a horrible and deadly danger

creeperton

.
#7
.

Vanya

It's funny how people think that computer science is related to normal computer programming.

All in all what math and physics disciplines you'll need depends entirely on what you plan to program and how detailed you want to be. For basic 2D programming, not trying to be particularly true to real physics you wouldn't need much more than basic geometry and elementary algebra. On the other hand if you're to go full 3D with relistic physics I'd definitely recommend trigonometry and advanced algebra. It's all relative.

Klarth

Quote from: Bregalad on August 25, 2012, 11:44:45 AM
The only reason those annoying calculus and physics course are mandatory in universities is just to show off, and to make sure only the most intelligent people makes it to higher degrees.
I used to think that way when I only programmed "normal" applications.  Since I've been involved in computational chemistry, my thought process has changed quite a bit.  The amount of math you need (for starters) requires linear algebra, multivariable/vector calculus, complex numbers, basic trigonometry, and 2nd order partial differential equations.  If you can't work with this kind of math, then you can't understand the field well enough to become a theorist.

DragonmasterX, you need to provide more information about the type of game you want to create in order for us to gauge the complexity.  Also whether you actually want to program a game engine or whether you just want to create a game.  If it's the latter, then maybe you can find a free game engine that suits your need.

DarknessSavior

Quote from: DragonmasterX on August 25, 2012, 06:30:32 AM
I gave up programming in college because I wasn't so great at it, and I was getting 100s on Japanese exams without studying, so I changed my major to East Asian Studies. So ultimately, how much math/physics is REALLY necessary in actual game programming  is something I've always wondered.
This sounds almost exactly like my story, except replace "programming" with "Psychology".

I can't speak as far as making your own game. But I learned to hack before I learned Japanese. And really, there is math involved. But when you think of it in terms of how a game works, it doesn't really SEEM like math.

I also took an intro Java programming course, and aced it with no problem. Again, math was involved, but I thought of it in terms of how to get my programs to work. It made it seem like less of a chore.

~DS
Red Comet: :'( Poor DS. Nobody loves him like RC does. :'(
Sliver-X: LET ME INFRINGE UPON IT WITH MY MOUTH
DSRH - Currently working on: Demon's Blazon, Romancing SaGa, FFIV EasyType.
http://www.youtube.com/user/DarknessSavior

Garoth Moulinoski

Quote from: Bregalad on August 25, 2012, 11:44:45 AM
Basically, what you learn in high scool is enough for game programming, exept if you want to code your own 3D engine where some basic linear algebra will be required but nothing too serious.

I'll be at that corner over there, crying myself to sleep until I forget I ever read this. Maybe one day, my dream will come true, but for now, nothing seems to lift my spirits and this certainly only brought down further than it was. :/
Who will quote me next?
Disclaimer: If it sounds wrong, I may have been posting while asleep.

henke37

I say, go for the sets and graphs instead of the complicated geometry. Basic trigonometry and percent is all you will need for 2d graphics.

FAST6191

Others have already I can find merit in all of what has been said thus far but I feel like waffling anyway

What I would say is better to learn and it comes in some parts of the world as part of maths is logic, mechanism design right up through basic game theory and similar fields and all have some fairly intense applied maths at their heart but the structures/methods at their heart at what most people spend years rederiving only to find they could have read a book and spared themselves the hassle.
To this end
Score progression by level- probably represented by an easy equation (x = x * 1.7 + 3000 where x at level 1 (or 0 if we are doing things computer style) is 10000) but the psychology that goes into the progression and the ability to cook up a series of variables designed to handle that and flow out into the game beyond it is both harder in a sense and more involved.
As for 3d not so many program their own game engine as opposed to buying in unreal and as time goes forward I suspect it will probably become akin to developing your own video codec if you want to be a film maker. Certainly a deep mastery of it will see things fall in your favour that otherwise might not but essential is a different matter.

Others seem to have befallen the common fate of almost having to do it by rote learning rather than being given the chance to play around with it-
Linguists how far did memorising verb tables and sentence construction get you vs having to write your first letter or similarly for programming.
Programmers the command list of a language and common data structures vs the time you had a task you had to automate and although doing it by hand would have ultimately been quick to go manual for (probably tedious but still quicker).
I could go on for other fields but it is pretty much always the same story- hard drive crash for computer fixing, psychology noting a trait that most would not unless trained to, mechanic doing something in six hours that would take the one that trained them half an hour but they did it, repeat previous for electrical engineering fault finding, a cook the first time you can ignore the recipe book or twist something to match preference/what they have, a photographer when they realise they can tell you exactly why your photo sucks (white balance, focus, iso setting......).......

Now I am sure you all went back and studied how these things work in depth eventually (certainly if you want to claim it as an ability) and in many regards you will not look back fondly on some of the lesser habits the messing around "before you were good" did for you.
By similar logic though I might argue that being forced to play in the real world will see you learn it quite fast assuming you are in a position to learn it (my favourite clients/jobs are those that say I know you are probably not an expert in this but you have a "paid" month to become one) not to mention it will probably be fun at this point.

There are three things I probably wish to note though- going back to read a book on the subject should probably be a higher priority than most other things, by doing the "hard" stuff it usually locks the easier stuff in by a marginally similar method to the applied examples I went on about and when playing academia it is probably there to weed out those that can not hack it or the more cynical side of me says those that will not do as well and drag stats down.

Disclaimer- I come from a heavy applied physics and maths background which I went into by choice with what I pass off as programming and computer related skills being things I picked up along the way; formal IT training for me begins with how not to completely suck at MS office and ends at matlab you can probably still use a spreadsheet for and lose absolutely nothing in doing. This said I am not entirely self taught in the traditional sense and I will often look to educational courses to get the syllabus there and in the last five years or so the online lectures and courses from so make of that what you will.

RedComet

If nothing else, the thought processes required to do higher level math is a valuable asset for programming. So even if you don't necessarily need to understand how to do calculus and physics for the game you're coding, there is a lot of intellectual value in it. I was in a similar place (pursuing a Japanese major because the classes were easy and then deciding to go for a CS major). I'm now in my third semester of calculus and at times being able to approach a problem from a different perspective has helped me immensely (i.e. saved me a ton of time) when I'm coding.
Twilight Translations - More than just Dragonball Z. :P

doop

I've always sucked hard at maths, so doing degree-level maths in my CS course has been a struggle, a lot of what they were teaching I ended up realizing was just to establish a way of approaching a problem with logic, which you end up doing all the time when programming. With games there will always be a degree of maths involved, even with 2D games. A lot of the code for my engine involves a fair few algorithms to determine drawing co-ordinates, optimizing resource loading, etc.

I think it all depends on how far you want to go, if you're writing an engine from scratch then regardless you'll be doing some complex maths to get the basic rendering going (that's if you're doing hardware accelerated drawing anyways), but if you don't plan on reinventing the wheel again then things are made a lot easier for you with the abundance of free rendering engines out there.

ETG

Think of math as a tool set. The more you know - the more you can use - the more you can do. Sure the computer will be doing all the calculations, but you need to understand the concepts at least.

One word: Vectors.
Learn about vectors and what you can do with them, then you will have an idea of how useful math can be.

My suggestion: make whatever games you can. Make embarrassingly bad games. Make short, dinky games. Use Stencyl, pygame, Unity, Game Maker, or anything else.

When your in school, study math eagerly. If your having trouble and can't see a point to learning it, know that you will later learn how to use it, or that it's vital to understanding a more advanced concept that will be immediately useful.

Geiger

Having actually done a bit of amateur game programming, you will need to know some calculus if you are writing the base 3D layer (not just linear algebra).  But typically, it is something you only need to be familiar enough with to figure out which formula to look up.  Back in my graphics course, I wrote a very basic version of the Ocarina of Time's shooting gallery mini-game.  I needed a formula from Calculus III to compute the position of a point on a sphere, for camera rotation.

If you stick to 2D, you probably will not need any calculus, but you may still need linear algebra if you get fancy with effects.

If you plan to do this professionally, you should know some calculus.  As much as your brain can handle.  (You can probably stop once you can compute the surface area of a saddle floating in space.)

Some basic physics will serve you well, but you probably do not need anything too advanced unless you are writing some sort of space simulator for NASA.
This is the patent age of new inventions -/- For killing bodies, and for saving souls, -/- All propagated with the best intentions. --Lord Byron

Zoinkity

Quotesome sort of space simulator for NASA
Like the Kerbal Space Program?

The tracks in F-Zero X are all cubic spline curves which use normals for orientation.  Through some clever functions it has a very fast random track generator that usually won't break AI.  It also exploits undefined values for jumps and loops.

Derivitives are too useful to be written off.  Keep in mind Newtonian physics were built via calc.  Averages of averages.  You wouldn't have things like The Gimp if it weren't for calc.  You also wouldn't have stock market predictions, so you really can use it for good or evil.

It all matters what you're doing.  You hardly need to fuss with it if you're focusing on sprite-based gaming, but even such simple matters as non-orthogonic perspective fall apart without a decent background.  The lower-level you go the more you need to know. 

SCO

The best programmers-as-creators (computer scientists) are also skilled mathematicians... they have to be since algorithms is what math is. Look at Knuth for a prototypical example
Even as a 'normal-straight-consumer' programmer you *need* some math, for instance big O.