# Tagged Questions

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.

952 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 ...
650 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 ...
3k 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, ...
364 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 ...
311 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 ...
4k views

### How do I linearly interpolate between two vectors?

I have a velocity vector where my client is at and where its going, and I have the same vector that comes from the server telling where the client should be. Sometimes its a bit different, so I want ...
1k 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 ...
2k 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 ...
1k 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 ...
2k views

### How to calculate the rotation resulting from ball bounce

Hey all, still working to incorporate more physics simulation into my game (mentioned HERE). Now having the ball successfully and quite realistically bouncing a surface it hits, I wanted to make the ...
310 views

### Deforming surfaces

I try to accomplish an deforming physic behaviour for levelsurfaces, but don't get an idea how to start with the implemenation so far. Regardless of the shape from the surface (planes, cubes, ...
595 views

### How to create a mathematical mechanism in order for a game to be balanced?

For example, in a game like Diablo, how did they decide how much damage each skill does? Is it the amount of clicks that the player needs to do? Or maybe the expected lifetime of a player? Maybe ...
354 views

### Make a fake random distribution?

Sometimes a "real" random event seems unfair and makes players frustrated. For instance a enemy has probability of 20% to cause double damage("critical hit"). Thus he could make 4 critical hits in a ...
796 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 ...
2k 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 ...
2k 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 ...
642 views

### Function for sun movement?

So, given a sun sprite set at the horizon (x = 0, y = worldheight/2) I'm trying to devise a function to make the sun rise, then fall. The best way to do this would be the sin function, but I have no ...
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 ...
497 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 ...
845 views

### 2D helicopter game, how to create corridor walls?

I'm looking into adapting the classic "helicopter" game (i.e. http://www.addictinggames.com/helicopter.html), but I haven't yet figured out how to create the walls-generation engine. Any pointers ...
299 views

### 100 points between 0-1000 on an increasing scale

Basically, it's for roleplay, I need to generate 100 points along a scale. Level 1 is the starting amount, and is at point 0 on the scale. Level 100 is the highest amount planned at this point, and it ...
290 views

### How do you calculate if 2 lines are facing toward or away?

Given the 4 points describing 2 line segments, how do you calculate if line A is towards or away from line B? The 2 lines have a fixed length, and can be measured as distance from x1/y1 to x2/y2.
558 views

### How does one separate the acceleration due to gravity from other motion in accelerometer input?

How does one separate the acceleration due to gravity from other motion in accelerometer input?
920 views

### Calculation of Inertia Tensors

Bit of a complex and lengthy question that, I'll admit, I don't quite understand very well yet so I will try and explain as best as I can. Short Version: Is there a general c++/physx formula out ...
2k views

### Float, double or both for 2D Vector class?

I'm currently writing a small cross-platform OpenGL-based 2D game engine for our studio. When I researched which 2D Vector class to use, I stumbled across three different design paradigms: Float ...
354 views

### Drone targeting

Imagine a "drone" and a target point on a 2d plane. There are eight parameters: P = my position Q = target position V = my velocity I = my moment of inertia w = my angular velocity s = my angular ...
313 views

### Render 3d object to 2d surface (embedded system)

i am working on an embedded system of a sort, and in some free time i would like to test its drawing capabilities. System in question is ARM Cortex M3 microcontroller attached to EasyMX Stellaris ...
433 views

### Building (simple) stellar systems

I'm currently looking at how to easily simulate some stellar systems (meaning some central stars and then some planets with maybe satellites), in order to allow later some space based strategy game ...
406 views

### Is there a (family of) monotonically non-decreasing noise function(s)?

I'd like a function to animate an object moving from point A to point B over time, such that it reaches B at some fixed time, but its position at any time is randomly perturbed in a continuous ...
872 views

### What are the most common splines you will find in game development?

List here the most common splines found in game development, how many points the method needs to interpolate a curve, and how can you build a data type that allows you to get an interpolation of the ...
571 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 ...
4k 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?
2k views

### Is there a simple way to do true isometric projection with an HTML5 canvas?

Is there a simple way to get a true isometric projection with the HTML5 canvas element?
6k views

### Sorting array of points in clockwise order

Is there such an algorithm to sort an array of 2D points in clockwise order? I'm specifically dealing with right triangle in my case so only 3 points. However I'm interested in knowing if such an ...
393 views

### make a sphere rolling on a roulette mesh stop at predetermined place

I have a roulette and a ball(sphere) placed on it. When the game begins the roulette spins. The spinning of the roulette and gravitational forces on the ball makes it roll along the 3d roulette mesh. ...
1k views

### Can someone explain the (reasons for the) implications of colum vs row major in multiplication/concatenation?

I am trying to learn how to construct view and projection matrices, and keep reaching difficulties in my implementation owing to my confusion about the two standards for matrices. I know how to ...
511 views

### What score/level function is often used?

In many games you raise a level when you reach a certain score, and later levels are harder to reach than in the beginning. I am suspecting that it is some sort of exponential function that is used ...
804 views

### Calculating Experience Points earned after a battle

I'm developing a simple text battle game and having some issues calculating how much XP should be earned after a battle, theres a few factors that i want to consider: 1) Players should of course earn ...
900 views

### Find a unit vector exactly halfway between two connected line segments

Seems like a quick and easy question but I haven't been able to find exactly what I'm looking for so: How to calculate a unit length vector that is pointing along the line which is exactly 50% of the ...
4k views

### What is a simple algorithm for calculating evenly distributed points on an ellipse?

I am looking for a simple algorithm to plot evenly distributed points on an ellipse, given the major and minor axes. This is really easy to do with a circle like so: var numberOfPoints = 8; var ...
305 views

### Slerping rotation mirrors

I rotate my game character to watch at the target using the following code: transform.rotation = Quaternion.Slerp(startQuaternion, lookQuaternion, turningNormalizer*turningSpeed/10f) ...
1k views

### Implementing 2D CSG (for collision shapes)?

Are there any simple (or well documented) algorithms for basic CSG operations on 2D polygons? I'm looking for a way to 'add' a number of overlapping 2D collision shapes. These may be convex or ...
2k views

### How to smoothly let an object move along a curved line

I'm wondering how to move objects, with rotation taken into account, to follow a curved line see: http://www.youtube.com/watch?v=iPpO24FeAX4 for an example In particular I wonder: how to store the ...
188 views

### How do I get the areas enclosed by an arbitrary 2D shape?

In my game I want users to be able to draw arbitrary 2D shapes of any length around game objects. The shapes must be closed and drawn with a single stroke that does not overlap. For example: I ...
2k views

### Rotating a vector by another vector in shader

I have a terrain surface with a normal for each point on the terrain. I have a second detail normal map to be applied to the terrain. These normals are in 3-space. The Y value of both normals is ...
502 views

### Why does the order matter in multiplication of matrixes?

I stumbled on this question because I had the same problem with my camera, and changing the multiplication order worked. I ran into a similar problem when scaling a model. This code produced the ...
3k views

### Does a minor in math increase my hirability?

I've been pondering this question for some months now, and have been unable to get an answer from anyone in the industry (likely because I know no one in the industry). I am currently completing a ...
2k views

### How can I render a circular progress bar procedurally?

I'm working in Flash AS3, but pseudo-code or any other language is fine. How can I make a circular progress bar? Akin to the ship bars in Pax Britanica, you can see them in the screenshot here. ...