Arithmetic, geometry, calculus, and all else which resolves the number-crunching necessary in a game. Math questions are those that deal with the formulae and calculations used by the game in various parts.
95
votes
17answers
27k views
What math should all game programmers know? [closed]
Simple enough question: What math should all game programmers have a firm grasp of in order to be successful?
I'm not specifically talking about rendering math or anything in the niche areas of game ...
50
votes
8answers
11k views
How to develop RPG Damage Formulas?
I'm developing a classical 2d RPG (in a similar vein to final fantasy) and I was wondering if anyone had some advice on how to do damage formulas/links to resources/examples? I'll explain my current ...
39
votes
4answers
793 views
How to determine which thrusters to turn on to rotate the ship?
The configuration of the ship changes dynamically, so I have to determine which thruster to turn on when I want to rotate the ship clockwise or counter clockwise. The thrusters are always axis aligned ...
28
votes
3answers
2k views
A ball hits the corner, where will it deflect?
I need to brush up my trigonometry and hope you can help here with a simple mathematical model. Here is my model so far in the image attached. I am aware that the frame animation has other problems ...
25
votes
5answers
3k views
Moving ships between two planets along a bezier, missing some equations for acceleration
OK, I already posted this over at math.stackechange.com but didn't get any answers :(
First of here's a picture of my problem, the description follows afterwards:
So I got all the points and ...
21
votes
3answers
2k views
Is there a faster sine function?
I am working on generation 3d perlin noise. The C# Math library seems like overkill for what I need since most of its functions use double percision. I use Math.Sin() in several places to generate the ...
20
votes
4answers
1k views
Are there any disadvantages of using Distance Squared checks rather than Distance?
I use distance squared checks for basically all my distance (vector3 length) checking, due to the performance increase from not incurring a square root (like in plain length checks).
From the looks ...
20
votes
6answers
3k views
What is a good linear algebra book for game programmers?
I was told that I should start learning Linear Algebra in order to create good games with good physics.
I'm reading Linear Algebra book and it's completely foreign to me. The author starts out with ...
20
votes
5answers
970 views
Beyond “Novice” Game Projects
I was reading this answer on the type of math a game developer should know and this part really stood out at me:
How do I move my game object? The novice might say:
"I know! I'll just do:" ...
19
votes
6answers
5k views
What are atan and atan2 used for in games?
I am having some trouble understanding Math.tan() and Math.atan() and Math.atan2().
I have basic knowledge of trigonmetry but the usage of SIN, COS, and TAN etc for game development is very new to ...
17
votes
7answers
1k views
What are some methods to represent train tracks?
I looked into this a while back for a small project, but didn't get too far. I'd like to create a small program that lets a user draw a train track and then allows a "train" to follow said track on a ...
17
votes
3answers
703 views
Building a Plattformer - How to determine if a player is allowed to jump?
I'm building a simple Plattformer Jump n' Run Style game. I do not use tiles - instead i've geometrical shapes for my level entities (and the player is one too). I finished my collision detection code ...
16
votes
2answers
583 views
Eight or infinity sign trajectory
When I want to move object around point I do:
point.x *= cosf(timer.timeElapsed);
point.y *= sinf(timer.timeElapsed);
How to make point move on eight or infinity sign trajectory?
16
votes
5answers
2k views
How can you visualize a quaternion?
When I visualise a three dimensional rotation matrix, or scaling matrix I visualize it as three axes.
Is there a similar way that I can visualize a rotation quaternion?
16
votes
1answer
546 views
Recreating retro/NES style physics with intentional imprecision
Background:
I'm having a problem getting the jump curve correct for a retro platformer remake project of mine. The original game is for the NES, and the player's velocity is stored in two separate ...
16
votes
2answers
492 views
How can I evenly fan out a hand of cards?
Given a set of playing cards (rectangle images with a width and height) how can I rotate and position each one so that they appear in a 'fan' pattern, much like you would hold a hand of cards in real ...
15
votes
7answers
528 views
Do I need a Point and a Vector object? Or just using a Vector object to represent a Point is ok?
Structuring the components of an engine that I am developing along with a friend (learning purposes), I came to this doubt.
Initially we had a Point constructor, like the following:
var Point = ...
15
votes
1answer
339 views
How to simulate early politics? [duplicate]
I'm making a historically accurate game where the player can interact with past times and shape the future. The entire game is scientifically generated with math and real physics. (no, it won't have ...
14
votes
6answers
9k views
Best C++ Math Library for Game Engine? [closed]
I'm looking for a fast opensource C++ math-library for my game engine
with the following features:
fast (sse?)
vectors
matrices
quaternions
suitable for both opengl and directx
14
votes
3answers
778 views
What does the graphics card do with the fourth element of a vector as the final position?
From this question it appears you would want a four-element position vector, as it is simpler to modify its position with matrix multiplication.
On its own this would imply the fourth element should ...
14
votes
1answer
1k views
How to convert mouse coordinates to isometric indexes?
I draw isometric map with tile 64x32:
const Offset = 160;
int X, Y;
for (int a=0; a < 6; a++)
for (int b=0; b < 6; b++) {
X = a * 32 - b * 32 + Offset;
Y = a * 16 + b * 16;
...
14
votes
3answers
1k views
Faking isometric graphics in a 2D space game
First off, I know exactly what my drawing problem is, and I have various ideas on how to approach solving it. I am here to figure out how to adjust which frame is drawn so that the isometric ...
13
votes
8answers
4k views
How should I sort images in an isometric game so that they appear in the correct order?
This seems like a rather simple problem but I am having a lot of difficulty with it.
What should I do to properly sort images in an isometric game?
In a normal 2d top-down game one could use the ...
13
votes
1answer
1k views
What are the maths behind 'Raiden 2' purple laser?
The path of the laser is affected by user input and enemies present on the screen.
Here is a video, at 5:00 minutes the laser in question is shown : Raiden II (PS) - 1 Loop Clear - Part 2
UPDATE
...
13
votes
3answers
324 views
How do you calculate the nearest point on 2 curves?
Given the points of a line and a quadratic bezier curve, how do you calculate their nearest point? .... Similarly, given the points of 2 curves, how do you get the nearest point?
12
votes
5answers
2k views
Do I need the 'w' component in my Vector class?
Assume you're writing matrix code that handles rotation, translation etc for 3d space.
Now the transformation matrices have to be 4x4 to fit the translation component in.
However, you don't actually ...
12
votes
1answer
2k views
Determine arc-length of a Catmull-Rom spline
I have a path that is defined by a concatenation of Catmull-Rom splines. I use the static method Vector2.CatmullRom in XNA that allows for interpolation between points with a value going from 0 to 1.
...
12
votes
5answers
2k views
What is the purpose of the canonical view volume?
I'm currently learning OpenGL and haven't been able to find an answer to this question.
After the projection matrix is applied to the view space, the view space is "normalized" so that all the points ...
12
votes
1answer
206 views
Orthographic unit translation mismatch on grid (e.g. 64 pixels translates incorrectly)
I am looking for some insight into a small problem with unit translations on a grid.
Update and Solved
I solved my own issue. See below for details. Everything in this part of the post turned out to ...
11
votes
4answers
615 views
How to get object to lose less velocity as its speed increases
I'm developing a game in Flash and I need a little help. It can be considered a math problem.
My object is flying with speed X and my object can collide with stones. When it collides with a stone, I ...
11
votes
5answers
550 views
Is there a common word that encompasses handling of position, rotation, and scale together?
I'm looking for a name for my class that manipulates 4x4 matrices that handle position, rotation, and scale. Is there a common word that encompasses all three?
(I'm splitting the matrix math into its ...
11
votes
5answers
5k views
Complete Math Library for use in OpenGL ES 2.0 Game?
Are you aware of a complete (or almost complete) cross platform math library for use in OpenGL ES 2.0 games?
The library should contain:
Matrix2x2, Matrix 3x3, Matrix4x4 classes
Quaternions
...
11
votes
8answers
898 views
Converting a 2D curve into points for data storage
I’ve created an algorithm which converts any curve i.e. path into minimum number of points so that I can save it into a file or database.
The method is simple: it moves three points in equal steps ...
11
votes
7answers
3k views
Comparing angles and working out the difference
I want to compare angles and get an idea of the distance between them. For this application, I'm working in degrees, but it would also work for radians and grads. The problem with angles is that they ...
11
votes
5answers
1k views
Quick 2D sight area calculation algorithm?
I have a matrix of tiles, on some of that tiles there are objects. I want to calculate which tiles are visible to player, and which are not, and I need to do it quite efficiently (so it would compute ...
11
votes
6answers
3k views
Math topics for 3D graphics programming
I understand that the following math topics are required for 3D graphics programming. I have started doing some of them in my math course. Can someone point me in the direction of a resource that ...
11
votes
5answers
5k views
Good 3D Math Theory Books [closed]
I've been developing a modification for the Source engine for well over a year, but am now facing some troubles with the weapons, gamemovement (player physics) and player feedback from explosives.
...
11
votes
4answers
543 views
How do I get AI Agents to move along a curve?
Currently my very basic AI framework has agents that move along a a jagged path made up of a series of points.
They do this by simply moving their position from one point to the next. When they ...
11
votes
1answer
743 views
Moving an Object along a Curve while Rotating it
I woud like to move an object along a curve. At particular points on the curve, I wish the object to change speed and rotate itself along its axis.
Imagine an airplane flying to a destination. It has ...
10
votes
4answers
895 views
Calculating the output of two armies fighting
I am programming a strategic game using Flash. The game works very similar to the famous game "Travian".
My problem is as follows: I am trying to make the calculation of the troops lost as a result ...
10
votes
2answers
931 views
Why do people use quaternions?
I have been using them as a black box for a while, I'm just learning about of the maths but I'd just like some definitive answers to this question.
So far the only benefit I've come across personally ...
10
votes
3answers
656 views
Random map generation - strategies for scattering/clustering random nodes
I am doing a simple 4X strategy game in space where each node is a point-of-interest (a planet, an asteroid and etc.).
To randomly generate a map, I would follow the steps below
Decide how many ...
10
votes
3answers
498 views
Animated examples of different interpolations formulas: any link?
I remember having spotted a link to a huge page with different equations to non linear interpolation curves, for example if you want to stop a car smoothly, etc.
Those can sometime be useful to ...
10
votes
1answer
2k views
How does UVW texture mapping work?
I'm trying to understand the mathematical theory behind UVW mapping. Can anyone explain me how UVW mapping works? Or at least provide me a pointer?
10
votes
5answers
854 views
How could you parallelise a 2D boids simulation
How could you program a 2D boids simulation in such a way that it could use processing power from different sources (clusters, gpu).
In the above example, the non-coloured particles move around ...
10
votes
2answers
459 views
Algorithm to shoot at a target in a 3d game
For those of you remembering Descent Freespace it had a nice feature to help you aim at the enemy when shooting non-homing missiles or lasers: it showed a crosshair in front of the ship you chased ...
9
votes
2answers
2k views
How can I rotate about an arbitrary point in 3D (instead of the origin)?
I have some models that I want to rotate using quaternions in the normal manner, except instead of rotation about the origin, I want it to be offset slightly. I know that you don't say, in 3d space, ...
9
votes
4answers
350 views
What exactly causes a surface to overlap another?
I cannot really figure out what causes one surface to overlap another. In a 3D engine I'm creating, my technique is failing in edge cases.
My method is sorting the surfaces to be painted from the ...
9
votes
4answers
231 views
Generate equal regions in a hex map
Taking for example large (X by Y) hex map, how can I divide the map into N regions of connected hexes to simulate countries?
The goal is to generate a hex map that looks like a real life map with ...
9
votes
2answers
978 views
How to make the player slide smoothly against terrain
I'm making an isometric game. When the player tries to walk diagonally into a wall I want them to slide smoothly across it, so whatever portion of the movement would be legal is used, and anything ...