Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [mathematics]

Mathematics questions deal with the arithmetic, geometry, calculus, formulae and other calculations used in the development of a game.

11
votes
3answers
3k views

Why use Time.deltaTime in Lerping functions?

To my understanding, a Lerp function interpolates between two values (a and b) using a third value (...
15
votes
2answers
13k 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, ...
163
votes
16answers
129k 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 ...
117
votes
12answers
104k 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 ...
8
votes
3answers
3k views

How can I launch a GameObject at a target if I am given everything except for its launch angle?

I am trying to launch an object at a target, given its position, its target position, the launch speed, and the gravity. I am following this formula from Wikipedia: $$ \theta = arctan \bigg( \frac{v^...
27
votes
7answers
4k views

Continuous weighted random distribution, biased toward one end

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 ...
19
votes
9answers
16k views

How do I sort isometric sprites into the correct order?

In a normal top-down 2D game one could use the screen y axis to sort the images. In this example the trees are properly sorted but the isometric walls are not: Wall 2 is one pixel below wall 1 ...
20
votes
4answers
20k views

Calculating minimum velocity of the projectile 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?
28
votes
10answers
59k views

In Pong, how do you calculate the ball's direction when it bounces off the paddle?

I'm trying to wrap my head around this very Hello World-y problem in game development. I've created a TicTacToe game in XNA so I guess the next step would be a Breakout clone. Keep in mind that I ...
25
votes
3answers
6k 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 ...
44
votes
2answers
18k views

How to create adjustable formula for RPG level up requirements?

I'm trying to create a formula that can be modified simply by changing two values: number_of_levels, and last_level_experience. This is to enable people modding the game to change the levelling ...
46
votes
7answers
51k 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 ...
21
votes
1answer
8k views

How to convert mouse coordinates to isometric indexes?

I draw isometric map with tile 64x32: ...
10
votes
1answer
8k views

How to balance experience gain in an RPG

I am currently developing an RPG game with a classic experience-points and levelup mechanic. The player kills monsters, gains experience points, levels up when they collect enough and become stronger. ...
8
votes
2answers
11k views

How to calculate shot angle and velocity to hit a moving target?

I am developing a 2D Android game and I am making an aiming algorithm for AI projectiles to hit enemies either following a path, or free moving. At the moment it just calculates where the target will ...
15
votes
4answers
3k views

How do I calculate rotation caused by bounce friction?

Following on from my previous question: I have the ball quite realistically bouncing from surfaces it hits. Now I'd like to make it spin from the friction of the hit. Showing this is simple enough: I ...
20
votes
5answers
16k 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 ...
5
votes
2answers
1k views

Why isn't this physics code scaling velocities separately?

I'm working my way through this book and I'm trying to work this code out: ...
12
votes
2answers
12k views

I am looking to create realistic car movement using vectors

I have goggled how to do this and found this http://www.helixsoft.nl/articles/circle/sincos.htm I have had a go at it but most of the functions that were showed didn't work I just got errors because ...
20
votes
4answers
3k 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 ...
27
votes
11answers
33k 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 ...
24
votes
3answers
6k views

How do I lerp between values that loop (such as hue or rotation)?

View Demo I'm trying to make the joint rotate smoothly around the center of the canvas, toward the angle of mouse pointer. What I have works, but I want it to animate the shortest distance possible ...
15
votes
6answers
17k views

How to rotate an object around world aligned axes?

I have a Vector3 which has an euler angle for each axis. Usually, when I want to create a rotation matrix I will use functions such as D3DXMatrixRotationX passing the respective angle from my ...
10
votes
2answers
3k 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 in ...
6
votes
2answers
8k views

How would I translate screen coordinates to Isometric coordinates?

I have a function isoToScreen(x, y) that converts Isometric coordinates to Screen coordinates. ...
7
votes
3answers
3k views

Create acceleration with direction

I want to move my object with an acceleration in the proper direction. For example if I have these values: friction = 0.3; direction = 180; speed = 5; For ...
47
votes
7answers
11k 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 ...
16
votes
5answers
24k 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. ...
47
votes
3answers
2k 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 ...
38
votes
2answers
9k views

Why do we use the Pythagorean theorem in game physics?

I've recently learned that we use Pythagorean theorem a lot in our physics calculations and I'm afraid I don't really get the point. Here's an example from a book to make sure an object doesn't ...
13
votes
1answer
21k 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 ...
11
votes
2answers
5k 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 ...
15
votes
3answers
2k views

Accurately simulating the lots of dice rolls without loops?

OK so if your game rolls lots of dice you can just call a random number generator in a loop. But for any set of dice being rolled often enough you will get a distribution curve/histogram. So my ...
13
votes
1answer
6k 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?
13
votes
3answers
28k 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 ...
12
votes
4answers
2k views

Animated examples of different interpolations formulas: any link? [closed]

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 ...
11
votes
1answer
7k 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 ...
11
votes
2answers
5k views

How to calculate the vector of an interception?

Given are a twodimensional space, and 1 friendly spaceship standing still, one foe is moving NOT directly to the friendly ship with known actual position, speed and direction. The friendly ship wants ...
9
votes
2answers
4k views

Can someone explain dual contouring?

I've been trying to understand voxel rendering and have been looking at dual contouring (DC). So far I understand this much: Run a density function for a set of grid points (i.e noise function) Find ...
5
votes
1answer
2k views

Algorithm for randomly generating reachable platforms

I want to randomly generate reachable platforms on the fly for a 2D game. Right now, I am just creating platforms at random x,y positions. Only 4 platforms can exist at once, so once the 5th one is ...
7
votes
3answers
4k views

building a game for different resolution phones

I am starting some tests for building a game on the Android program. So far everything is working and seems nice. However I do not understand how to make sure my game looks correct on all phones as ...
5
votes
1answer
7k 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 ...
0
votes
1answer
8k views

RPG Logarithmic leveling formula?

I'm working on a RPG game, however, I am not the amazing person at math that I wish I was, although someone suggested a logarithmic equation would work well. My current idea is for this: You start ...
1
vote
3answers
1k views

Code to generate a color gradient within a texture using a diagonal line

I want to generate a color gradient between two colors from x1,y1 to x2,y2. I'm unsure how to do this though. I can use Color.Lerp to get all of the color steps, but the problem is that I don't ...
1
vote
2answers
641 views

Object orbiting a 3d sphere

I'm developing in libgdx java/android but not using any high-level environment like Unity. I have a sphere at [0,0,0], with a PerspectiveCamera looking at it. Through the main game loop I have ...
1
vote
2answers
1k views

Lookrotation of a gameObject in just one axis

So I am trying to orient a gameObject ( house in the picture below) which is nothing but a plane and has a 2d texture on it as you see below. The whole game is made on a hex sphere. I am using ...
46
votes
4answers
7k 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 ...
24
votes
3answers
52k views

Moving an object in a circular path

I want to move one object (dot) in a circular path. How should I change the X and Y coordinates to accomplish this?
21
votes
6answers
9k views

What is a good linear algebra book for game programmers? [closed]

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 ...
18
votes
2answers
10k views

How can I generate a navigation mesh for a tile grid?

I haven't actually started programming for this one yet, but I wanted to see how I would go about doing this anyway. Say I have a grid of tiles, all of the same size, some traversable and some not. ...