Forum Thread
by member
  Posts  
Programming-related Math Tutorials? (Forums : Coding & Scripting : Programming-related Math Tutorials?) Locked
Thread Options
May 9 2013, 9:04pm Anchor

Are there any good tutorials or websites that can teach me all kinds math but show examples and relate to programming/game-programming? I keep getting problems with my code and they're all math-related so I'd like to be able to help myself. I know basic algebra and geometry, keep in mind I'm only 15, but it seems I need to know all kinds of math.

Metalspy
Metalspy Basher of Drums
May 10 2013, 6:13am Anchor

Can you give an example of a problem you have run into? And are you using a game engine or are you writing one yourself? Because my experience with game engine is that I don't really need that much 'advanced' math, just basic math which I used for positioning of objects. Having knowledge of matrices can be helpful, although I have developed games for years without even knowing what a matrix was.

I don't know if there is such a site you are asking for, but searching around and getting your information from different websites instead of having a one-site-knows-it-all shouldn't be a problem I hope? If you encounter a problem, just search the web and you will most likely find your answer. It takes a bit more time that way, but if you really want to develop games it will be worth it.

ambershee
ambershee Nimbusfish Rawks
May 10 2013, 6:29am Anchor

Stuff you want to know is geometry, vectors, matrices and trigonometry. With more advanced stuff, an understanding of integration and differentiation (calculus) is also useful. Usually, you should be able to google answers to specific questions, so long as you phrase them ambiguously enough.

There are some fantastic textbooks out there which don't cost too much and cover the lot, I would recommend picking one up.

Edit: I have a copy of this one and it's excellent. It probably covers more material than your entire high-school education does ;)
Amazon.com

Edited by: ambershee

May 10 2013, 9:45am Anchor
Metalspy wrote:Can you give an example of a problem you have run into? And are you using a game engine or are you writing one yourself? Because my experience with game engine is that I don't really need that much 'advanced' math, just basic math which I used for positioning of objects. Having knowledge of matrices can be helpful, although I have developed games for years without even knowing what a matrix was.

I don't know if there is such a site you are asking for, but searching around and getting your information from different websites instead of having a one-site-knows-it-all shouldn't be a problem I hope? If you encounter a problem, just search the web and you will most likely find your answer. It takes a bit more time that way, but if you really want to develop games it will be worth it.



I'm coding my own "engine" for my game and it is 2D so I don't think I need matrices.

May 10 2013, 9:46am Anchor

If you want to have a good understanding rather than a surface understanding then coursera will be starting a linear algebra course this June.

If you just want to enough to get started then learn the basics of vectors and vector transformations.

May 10 2013, 9:46am Anchor

The problem I'm having is I'm making a sort of RTS game and I can't get the select box that you can with your mouse to properly select units. I believe the problem is that sometimes the select box can be negative width and height and the units hitbox is always positive so the the program doesn't think the two are intersecting. I'm also having a problem moving the units you select to a point you click at a constant rate, it just depends how far away they are from the point you clicked and then they just zoom there with no predictable speed.

May 11 2013, 7:02am Anchor

There is gamedev.net where the community released a bunch of new math tutorials, but I don't know about the quality of those articles.
To get the selection box working, don't forget to mind the position of the unit, and that the box is around it (e.g. pos.x +- 0.5*box.x).

For your problem with the movement speed, you need to use normalized vectors (vectors of length 1.0, you get them by dividing all their values(x,y) by their length), maybe this basic code snippet can help you:

c code:
vec2 diff = click.position - unit.position;   // difference-vector pointing from unit to click

float length = SQRT( diff.x*diff.x + diff.y*diff.y );   // length of the difference-vector

vec2 norm = diff / length;   // the normalized difference-vector has length 1.0 but points in the same direction

vec2 velocity = norm * MIN( 4.0, length*10.0 );   // basic movement velocity with max speed of 4.0 and smooth brake at distance 4.0/10.0

And even if you are just working in 2D, matrices can still be useful (they are typically 3x3 instead of 4x4), so I would recommend learning at least the basics. Best example for matrices in 2D is the rotation of objects, it's much easier and faster that way.

Best regards
- Martin

Edited by: MausGames

May 11 2013, 8:27am Anchor

It looks like you need problem solving skills rather than maths. Define your problem, set boundaries ( i.e. may I sacrifice some speed to get precision? ), translate the real world into maths, think, think again, think some more, try an approach to the problem. Repeat until you're satisfied.

Maths are a tool to describe the world, and most of the formulas ( specially the ones you'll use ) are already there and a computer may solve them most times easily. But you have to tell the computer WHAT to solve.

Usually when someone can't come up with a solution to a problem, it's because they haven't defined the problem correctly. Try to expand on the ideas that define the problem, i.e. 'What is a selection box? How does it work? What defines the area of a unit? ... ' and such questions will help you understand.

Hope I was of help.

May 21 2013, 10:44am Anchor

Im not a great programmer however perhaps these links will prove useful ?
En.wikipedia.org
Hobbygamedev.com

--

Stress is when you wake up screaming & you realize you haven't fallen asleep yet.
Don't force it, get a larger hammer.
I tried to daydream, but my mind kept wandering

Reply to Thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.