# 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.

730 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 ...
614 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 ...
3k 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?
1k 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 ...
717 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, ...
367 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 ...
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 ...
336 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 ...
299 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.
5k 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 ...
941 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 ...
331 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, ...
608 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 ...
368 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 ...
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 ...
869 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

### 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 ...
658 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 ...
541 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 ...
870 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 ...
317 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 ...
611 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?
1k 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 ...
330 views

### Modify random distribution functions :: Make it less likely to get multiple similar values in a sequence

I want to generate a sequence of numbers for procedurally generating planets in a galaxy sector. Each planet should be placed randomly, however it should be very unlikely that two planets are directly ...
427 views

### Can I jump from A to B?

I'm making some rudimentary AI for my side-scroller and I need to know whether an AI unit can reach point B from point A simply by taking a jump. Flight trajectory of my characters is a bit unusal as ...
365 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 ...
327 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 ...
437 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 ...
412 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 ...
607 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 ...
5k 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?
442 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 ...
573 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 ...
846 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 ...
939 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 ...
5k 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 ...
328 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 ...
266 views

### RK4, Derivatives, Understanding Game Physics

Gafferon Games has a great article on RK4 Integration for building physics simulations which can be found here: Integration Basics Personally my mathematics and physics knowledge could use ...