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.
93
votes
17answers
26k 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 ...
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 ...
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;
...
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, ...
44
votes
7answers
10k 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 ...
9
votes
4answers
874 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 ...
4
votes
3answers
1k views
Determine Resulting Angle of Wall Collision
So I have an object moving in a direction towards a fixed horizontal or vertical wall. How do I compute the angle that the object should bounce off at? The object can approach the wall at an arbitrary ...
11
votes
5answers
4k 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.
...
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 ...
6
votes
1answer
3k views
Get position of point on circumference of circle, given an angle?
I would like to know how to get a specific point on the circumference of a circle, given an angle. The diameter of the circle is 1, and the center point of the circle is { X: 0.5, Y: 0.5 }.
14
votes
3answers
742 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 ...
10
votes
3answers
482 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 ...
3
votes
1answer
2k views
How do I find rotation in 3D based on a vector/normal?
I've been playing with Blender and Python, doing basic things like accessing vertices/normals,etc.
I can get the normal of each face of a mesh. I was wondering, how can I get the rotation of a face ...
1
vote
3answers
374 views
Create acceleration with direction
I want to move my object with an acceleration in the proper direction. I'm not good at math so I need some help. The example in Game Maker is:
friction = 0.3;
direction = 180;
speed = 5;
But I'm ...
3
votes
5answers
511 views
How to randomly place rectangle inside a larger bounding rectangle without intersecting other rectangles inside
Let us consider the case: there is an overall bounding rectangle (call this Rb) which contains a number of rectangles within it (call this set SRo). Now I would like to randomly position a new ...
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 ...
10
votes
5answers
835 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 ...
8
votes
6answers
1k views
Weighted Random Distribution
I am currently contributing to a particle system for our game and developing some emitter shapes.
My uniform random distribution along a line or along a rectangular area works fine - no problem.
But ...
9
votes
1answer
387 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 ...
7
votes
1answer
2k views
Circle-Line Collision Detection Problem
I am currently developing a breakout clone and I have hit a roadblock in getting collision detection between a ball (circle) and a brick (convex polygon) working correctly. I am using a Circle-Line ...
9
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?
3
votes
1answer
273 views
rotating an object from sourceAngle to destAngle, both 0-359, clockwise or counter clockwise?
I've got a game object i need to rotate. It's current angle is player.rotation, the destination is targetAngle, both in degress, 0 to 359. I've got a function named rotateDirection(float sourceAngle, ...
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
...
9
votes
1answer
1k views
Angle of Reflection
I have this "Breakeout style" game.
I have a cannon at the center, blocks around the cannon and pads around the blocks. This is how the game looks like:
I've managed to get the collision per ...
6
votes
4answers
2k views
Calculating velocity needed to hit target in parabolic arc
If I have a point which I want to hit at the end or during a parabolic arc, how would I calculate the needed x and y velocity?
8
votes
3answers
1k views
How to move an object along a circumference of another object?
I am so out of math that it hurts, but for some of you this should be a piece of cake.
I want to move an object around another along its ages or circumference on a simple circular path. At the moment ...
5
votes
1answer
381 views
What is the best way to limit player movement?
I'm currently programming a 2d game where the player moves around on a rectangular playing field. The player has a direction and a velocity. What is the best way to limit the player's movement so ...
4
votes
2answers
857 views
Matrix for 2D perspective
I'm trying to determine whether what I'm attempting to achieve is even possible mathematically. I'm obviously not a seasoned game developer so I'm having trouble even coming up with the terminology to ...
4
votes
1answer
584 views
AABB - AABB Collision, which face do I hit?
To allow my objects to slide when they collide, I need to :
Know which face of the AABB they collide with.
Calculate the normal to that face.
Return the normal and calculate the impulse that to ...
1
vote
3answers
219 views
Inverting matrix then decomposing gives different quaternion than decomposing then inverting the quat
I'm getting different signs when I convert a matrix to quaternion and invert that, versus when I invert a matrix and then get the quaternion from it:
Quaternion a = Quaternion.Invert(getRotation(m));
...
20
votes
5answers
961 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:" ...
17
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 ...
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
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.
...
7
votes
5answers
3k views
SIMD C++ library
I've use Visual Studio with the DirectX XNA math library. Now, I use the GNU compiler collection. Can anyone advise a SIMD math library with a good documentation?
8
votes
4answers
1k views
Staggered Isometric Map: Calculate map coordinates for point on screen
I know there are already a lot of resources about this, but I haven't found one that matches my coordinate system and I'm having massive trouble adjusting any of those solutions to my needs.
What I ...
10
votes
2answers
920 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
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 ...
16
votes
2answers
564 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?
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
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 ...
10
votes
7answers
2k 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 ...
9
votes
2answers
956 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 ...
7
votes
4answers
647 views
Not sure how to handle “deceleration”
I say "deceleration" because I'm not using acceleration at the moment (it is being calculated, it's just set to 0 0); what I mean is moving the velocity back towards zero, eventually stopping.
I'm ...
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 ...
9
votes
1answer
954 views
Adding air drag to a golf ball trajectory equation
I'm developing a 2D golf game in VB.NET 2005, but I am stuck on how to implement air or wind drag that should affect the ball.
Already I have these equations for projectile:
Vo ...
7
votes
5answers
525 views
Circular Bullet Spread not Even
I'm creating a bullet shooter much in the style of Touhou. Right now I want to have a very simple circular shot being fired from the enemy.
See this picture:
As you can see, the spacing is very ...
7
votes
1answer
343 views
Projected trajectory of a vehicle?
In the game I am developing, I have to calculate if my vehicle (1) which in the example is travelling north with a speed V, can reach its target (2). The example depict the problem from atop:
There ...
6
votes
2answers
165 views
How do you calculate if a line is facing a curve?
Given the 2 points describing a line segment, and the 3 points describing a quadratic bezier curve, how do you calculate if the line is facing towards or away from the curve?
The line has a fixed ...
6
votes
2answers
2k views
How to think about 2D scaling/rotation transformations
This is a kind of embarassing question to me since I'm getting more in-depth with XNA but some times my way of thinking about things in my head contradicts an example and I need to re-think it to make ...