Essential mathematics for programmers

Hey guys I trying to do a bit of programming tutorials here and there and usually I get it without much trouble. That is, until some math equations come into play. Then I get lost cause I never learned that stuff.

What recommendations you guys got for essential math skills? Even better if you can say what kind of game programming problems require which kind of math.

Thanks!

Btw, there is some books I am reading about this and much written already, I just want to get more opinions is all.

1 Like

I don’t think this is really trivial question.
Your game math complexity may greatly vary from game to game.
If you do 2D game, some math may be different than for 3D games. For example finding xy using sin / cos, vs finding xyz using quaternions.
Saying that most complex math is done for you, with build in methods.

Things start get complex, when you want to do path finding, AI, relative orientation in space (i.e. projecting on planes etc.).

I don’t try learn basics equation prior need, because I never know, what I may need next. I just try figure out what I need, when working on the problem. Still often may be none trivial.

Plus to add to pile, every solution has at least multiple other solutions.

I find this geogebra very useful. But requires a bit of search, to find what you need.
Also may give some ideas.

There are tons of website talking about math in programming, but few extra

Also this one, often recommended on this forum

4 Likes
4 Likes

Personally I’d focus on being very familiar with the math helper classes and their functions in the scripting reference, and having a strong understanding of what they do and how they can be used. When you work through a tutorial that doesn’t abstract away the math, you can either focus on understanding what they do in their equations, or focus on trying to understand what they are trying to achieve and see if you can substitute their equations with usage of the available math helper functions. I usually try to stay focused on “what and why” and “abstract away” the math if it’s complicated. Extending the math helper functions as needed will be good practice in and of itself. E.g. on a 2D game project I once wrote a function for [RotatePoint: p1 aroundPoint: p2 by: degrees], and once I had googled and copied from stackoverflow found a solution for the implementation, I only ever used the helper function for this task.

But I’m not a “real programmer”, so it might be bad advice and I might be underestimating how far the math education that I had in school goes, compared to other countries, other school types and other self-chosen course specializations, because I took the “advanced level math course”, so vectors and matrices are still considered “school level math” for me. YMMV

4 Likes

What kind of math are you running into?

1 Like

Many American 4-year Computer Science programs require a year of Calculus. That gives the false impression you need math to be a programmer, but it’s mostly used as a weed-out (my source: curriculum committee meetings at a state university). Knowing how to read math like f(g(3)) and f(x,y):N->N = 2x+y is helpful for learning to code. That’s 8th grade(?) algebra. But trig, calc, linear equations … aren’t useful. Depending, they could be, but so could accounting or genetics.

For Unity, you should be comfortable with standard vector math. p1+p2 assumes p1 is a point, and p2 is an arrow, and gives you a point as the result. p3-p1 assumes both are points and gives an arrow. I think that’s in High School, somewhere.

2 Likes

@Billy4184 , basically anytime a math function is used I immediately become lost. I’ve been doing basic intro to unity tutorials and some character controllers.

I understand and agree what Martin is saying. I don’t want to memorize all the formulas, but I need to understand what kind of problems need solving and common tools used to solve them.

In Owen reynilds example, for instance, I do not know how to read his equation or have an idea what it is doing.

The goal is not that I am trying to be a programmer, I just want to be able to understand things a bit better so I can do more simple prototyping on my own.

Thanks everybody for resources so far.

1 Like

Regarding basics method, as already mentioned, I suggest use VS intelisense, which show possible options. Same thing you can go to documentation, but I like check option on the fly.

So for example, you type Vector3. and you see options, of what you can do with vector. Cross, Look toward, project, dot, and more. Then you check description of these magic methods. They may sound gibberish at glance, but is worth to get yourself familiar, what they can do. Just read upon, on internet, where such can be used. Not only docs, which is often pain to follow, as is dry as desert weather.

Then next time you run into a problem, you will click and realize that you read somewhere about potential solution. So now you are a step closer to solving a problem. You search again, and all comes to you. All then becomes a bit easier, as such terms are no more alien. :slight_smile:

Btw. to a little encourage, I was really bad at phys and math at school. Maybe more, I wasn’t interested at that time. But I play with it now on fail bases.

2 Likes

Hey I happened to notice your Dog Go Run game in your sig (looks cool btw). I watched a video and noticed the dog is still horizontal on angled slopes. Is that the sort of math stuff you mean?

My best suggestion about math is to turn it visual in any way possible at all, and avoid trying to understand concepts beyond their utility unless you need to.

For example, let’s say you want the dog to be aligned with the terrain. Logically, the first step is that you need to know ‘where the terrain is pointing’. Thats what a mesh/raycast normal vector can give you. Do you need to know any more about normals, beyond knowing which API to call to get it? probably not.

Then you visualize how the mesh normal helps you align the dog. What property of the dog can you relate to the mesh normal? The dog’s ‘up’ direction. How can you align the dog? With the Transform.LookAt function.

But how do you align the dog when Transform LookAt function aligns the ‘forward’ direction, not the ‘up’ direction?

Well, a useful thing to know is that the Vector cross product is not just some mathematical abstraction, it has a utility that’s very practical. If you do the cross product of two vectors, you get a vector that is 90 degrees to both of them. So if you have the ‘right’ vector and the ‘up’ vector, the cross product can give you the ‘forward’ vector. With that you can use Transform.LookAt and align the dog in the right direction.

The key thing is that you can break up the problem into a set of very specific questions just by doing a simple mental analysis. At each of these questions, you can probably google and find a useful answer. And in the end, very little actual math ‘ability’ is needed to make use of the mathematical functions.

4 Likes

@Billy4184 perfect example.

Yeah I can usually visualize what I want to do, it’s just a matter of knowing what tools are there that I can do it with (or knowing about tools I have no clue exist for smarter solution)

1 Like

I would echo everyone else and say a rudimentary understanding of calculus is important, trigonometric functions, operation functions in the real and complex domain is useful, basic knowledge of artificial intelligence, neural nets perhaps tensorflow which is <3 and ultimately starting to get to grips with Dots, this is for asynchronous programming and using multi cores properly. Good luck!

1 Like

Only to fall to your knees at the altar of Quaternions!

5 Likes

P.S congrats to the hippo for not passing off the advice in this thread as too complex and just hubris, and concluding ‘just make a game, even if you have to use visual scripting’. You are growing wise my padawan :smile:

Wut maths are best for mmo tho?

Multiplayer, 100vs100, and procedural everything ples.

I don’t often make MMO games as a one man indie but when I do it’s AAA

2 Likes

There is this YouTube Channel were you can find math explanations for various game related things:
https://m.youtube.com/playlist?list=PLW3Zl3wyJwWOpdhYedlD-yCB7WQoHf-My

4 Likes

Also

1 Like

Quaternions, matrix math, trigonometry, and enough calculus to understand the relationship between position, velocity, and acceleration. Also binary logic.

1 Like

Generally I found out that the math is only as complex as the notation, once translated in layman’s it’s generally dead simple.

Also a lot of formula aren’t actually equation, they are description, ie you can’t use them unless you reconstruct the term on your own For example stuff like F(x)D(x)G(x) is not useful unless you look for what they are intended to represent (here it’s the fresnel term, the distribution term and the geometric term)

For example the scariest equation you find on internet are integral and big sigma, which in practice you gonna do a for loop, with the difference is that integral is summing sample*delta, while big sigma is just summing the samples.

For example neural network look scary until you realize that’s the same math than a supermarket ticket, which is trivial, a single receipts being equivalent to a perceptron when you look at the result and decide if it’s over budget or not :smile:

The other scary thing is all the symbol dialects, that is each math has is niche notation that get close but sometimes diverge, for example in shader omega tend to mean hemisphere or sphere, theta and phi are angle (horizontal and vertical respectively). But one doofus will use the omega to denote weight, and you can only understand if you are familiar with the subject already.

Also pi and radian use to be that stuff that makes you feel mathy, until you realize that in practical term pi is just half a cycle, so 2pi is a circle, substituting 2pi by circle make anything WAY more clear, you don’t even convert to degree anymore because radiant are just fraction of circles, half a circle is easier than 180° or pi.

I have read some damning thing, for example the mcGuire SSGI paper is full of unnecessary implicit jargony notation dialect, if I hadn’t read hundreds of other paper on GI would had scare me away.

It’s a lot of unnecessary obfuscation.

3 Likes

I have a master of science degree (well I don’t have the degree since I’m a drop out, but close enough). I read a course in linear algebra which is the basics of vector and matrices math. It’s really good to get the basics to understand the higher functions in 3d gfx