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.

40k 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 ...
20k 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 ...
1k 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 ...
1k views

Why are radians preferred over degrees in game development?

I've been looking up the definition of radians and found out that mathematicians prefer them because they are derived from pi instead of being completely arbitrary like degrees. However, I have not ...
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 ...
4k 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 ...
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 ...
2k 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 ...
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 ...
1k 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:" ...
9k 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 ...
884 views

Forgive me if this isn't considered a real question, but it is something I am genuinely confused about. I constantly hear other game developers talk about how using vectors are very useful, but also ...
2k 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 ...
2k views

How to optimize the distance function?

While developing a reasonably simple RTS-like game, I noticed my distance calculations were causing an impact in performance. At all times, there are distance checks to know if a unit is in range to ...
949 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?
506 views

How can I maintain a rectangular formation when units are added or removed?

I've got bots in a rectangular formation with rows and columns. A problem arises when a bot is added or removed from the formation. When this happens, the bots have to rearrange themselves so that the ...
733 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 ...
3k 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?
645 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 ...
592 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 ...
585 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 = ...
3k 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; ...
554 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 ...
12k 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
1k 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 ...
3k 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. ...
2k 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 ...
1k views

Bezier curve arc length

How can I find the distance traveled by a Bezier curve? For example, the distance traveled by a Linear Bezier Curve is: distance = sqrt(pow(x[1] - x[0], 2) + pow(y[1] - y[0], 2)); But what about ...
435 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?
602 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 ...
2k 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 ...
3k 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 ...
2k 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 ...
351 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 ...
1k 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 ...
7k 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 ...
4k 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 ...
4k 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 ...
6k 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 ...
3k 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 ...
2k 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 ...
245 views

Accounting for waves when doing planar reflections

I've been studying Nvidia's examples from the SDK, in particular the Island11 project and I've found something curious about a piece of HLSL code which corrects the reflections up and down depending ...
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 ...
636 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 ...
2k 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 ...
452 views

How do I find a point on a line?

I have two points (A, B) and the length of d. How can I find point C?
1k 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 ...
7k 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. ...