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

813 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. ...
331 views

### How to generate random points on the surface of a quadrilateral

Alright, I'm sure there has to be a simple way to do this but it eludes me at the moment. I want to be able to generate random points on the surface of a quadrilateral in 3D space. (Defined simply as ...
821 views

### Zooming and panning a camera simultaneously causes a swooping effect

In a 2d game, I have a basic camera class. The guts of the class creates a transformation matrix that is later passed to the Begin() method of a SpriteBatch. The transformation is done like this: ...
599 views

### 2D car physics and high speed turning

I've been looking at the following page, which has been very helpful: http://www.asawicki.info/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games.html but have come into problems with the ...
684 views

### How to render metaballs?

How to render metaballs? I am a Python programmer familiar with the Panda3d and Blender3d APIs. My math kinda sucks, but I know enough to write game logic code and procedural model generation code, ...
146 views

### Drawing a line from a random coordinate through a given point

When the mouse button is clicked, I want to draw a line from (0, random) to (640, y) which goes through the click position. How would I calculate the y coordinate of the end of the line?
1k views

### top down game - checking, drawing enemy's line of sight area with obstacles

Examples of what i'm going to need: I'm using cocos2d to draw a CCTMXTiledMap, on those tiles i'll have to draw the LOS cone. How would i test if the player is within that cone, taking obstacles ...
392 views

### Is there a better way of determining direction to turn?

You have an entity A that you want to turn towards another entity B. One way to determine the direction to turn is to compute the cross-product of the direction vector of A with the vector from AB. ...
520 views

### Manipulating a free camera

I have a camera class in my code which stores two 4x4 matrices. One for the view matrix and one for the projection matrix. Originally, I had two floats in the class for pitch and yaw and these were ...
227 views

### A* for non grid network

For my specific case, I am trying to find a path finding implementation similar to what described here. I could see reference implementation for A* and HPA*, but I wonder how to extend A* to simple ...
1k views

### How do I calculate the normal of a plane defined using homogeneous coordinates?

I can define a plane in 3D space using three 3D points (p0, p1, p2) that all lie in the plane and that form a non-degenerate triangle. Calculating the normal of the plane is as simple as calculating ...
886 views

### Arrays for a heightmap tile-based map

I'm making a game that uses a map which have tiles, corners and borders. Here's a graphical representation: I've managed to store tiles and corners in memory but I'm having troubles to get ...
189 views

### Plotting entities on a radar

I'm trying to build a radar system like the one in the original X-Wing games. The way it works is that there are two circular radar systems, one for behind the ship, and one for infront. So, I've ...
2k views

### Is it possible to map mouse coordinates to isometric tiles with this coordinate system?

I'm trying to implement mouse interaction in a 2D isometric game, but I'm not sure if it's possible given the coordinate system used for tile maps in the game. I've read some helpful things like ...
741 views

### Predicting physics/trajectory for pool/billiards games

I'm thinking of making a quick proof of concept of a billiard-style game mechanic, where the player has perfect information of what is about to happen. Here's a good example: I'm only mildly ...
1k 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 ...
5k views

### OpenGL ES 2.0: Understanding Perspective Projection Matrix

Setting the Perspective projection matrix in Open GL (including OpenGL ES 2.0) has the following general format: glm::mat4 perspective(float fovy, float aspect, float zNear, float zFar); Notice the ...
277 views

### Realistic damage

I'm looking for a good way to simulate damage, for example a weapon firing at a ship it would calculate the damage depending on layer type, weapon type, angle and similar what i need is a way to to ...
177 views

### Finding roots/zeros for collision detection?

For the most simple of 2D games, I have implemented a posteriori collision detection (overlapping rectangles) on the x/y Cartesian plane, but am now interested in understanding the basics of a priori ...
308 views

### Robust line of sight test on the inside of a polygon with tolerance

Foreword This is a followup to this question and the main problem I'm trying to solve. My current solution is an hack which involves inflating the polygon, and doing most calculations on the inflated ...
199 views

### Preventing ties

I'm working on a simple game to rate a users' preference among several styles. There are C classes, and the game consists of R rounds of comparison. At each round, the user is presented a ...
2k views

### Local to World coordinates in 2D and back

I'm getting back into hobby game programming after a long 4-year hiatus from college and I find that my understanding of coordinate systems is somewhat lacking. I'm trying my skills at creating a ...
373 views

### How do I create weapon attachments?

My question is; I am developing a game for XNA and I am trying to create a weapon attachment for my player model. My player model loads the .md3 format and reads tags for attachment points. I am able ...
760 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 ...
560 views

### Literature for Inverse Kinematics: Joint Limits and beyond

Recently I've been playing around with Inverse Kinematics and have been pretty impressed with the results. Naturally I want to take it further, but have no clue where to start. In particular, I would ...
514 views

### Isometric - precise screen coordinates to isometric

I'm trying to translate mouse coords to precise isometric coords (I can already find the tile the mouse is over, but I want it to be more precise). I've tried several different methods but I seem to ...
2k views

### Get angle in radians given a point on a circle

I'm working on a dial that rotates around a circle. This dial should lets you mousemove anywhere in a circle to adjust the position of the dial to a point on the circle with the same angle as the ...
349 views

### How do I use the dot product to get an angle between two vectors?

I am learning to use normalized vectors in my games. I've learned that in order to know the angle between two vectors, I can use the dot product. This gives me a value between -1 and 1, where 1 ...
4k views

### GLM: Euler Angles to Quaternion

I hope you know GL Mathematics (GLM) because I've got a problem, I can not break: I have a set of Eular Angles and I need to perform smooth interpolation between them. The best way is converting them ...
2k 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 ...
1k 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 ...
343 views

### Predictive firing (in a tile-based game)

I have a (turn-based) tile-based game, in which you can shoot at entities. You can move around with mouse and keyboard, it's all tile-based, except that bullets move "freely". I've got it all ...
3k 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 ...
368 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. ...
1k views

### Random Vector within a cone [duplicate]

I'm looking to create a random vector within a cone given the radius (base). It feels like I've been traversing through many pages on the internet and still I'm no further forward to getting an ...
1k views

### Normal transformation and homogeneous coordinates

I'm very confused about the math behind the model/affine transformation expressed in homogeneous coordinates. Reading this article, I understood that a generic vector is transformed by multiplying it ...
844 views

### A good place to learn about Game Programming with Mathematical Vectors?

I am looking for a place in the web where I can turn my current game development process into a vector based approach. I am sorry If this question has been asked once. According to my google search ...
113 views

### Propel entities at some angle (depending on explosion's position)

I have a 2D platformer. There are multiple particles that are just 1x1 colored pixels. Let's assume there are 256 particles laid out as a 16x16 cube. Say I popped an explosion right in the middle. All ...
301 views

### What should be taken into consideration when choosing a math library for games?

I'm currently selecting a C++ math library to use for a project. There are several questions here and on SO concerning the 'best' library available and many answers with different suggestions, but I ...
1k views

### How to find two perpendicular lines given a single plane

Hey guys, i was wondering how i would go about finding the perpendicular lines relative to a surface normal. For instance say i have (0,0,1) the expected output would be (1,0,0) and (0,1,0). What ...
264 views

### The physics equation for a perpetual seesaw

I am trying to create a game that involves two or more people jumping on a seesaw and propelling each other in the air. I need help with the physics equations Assume no friction and no air ...
150 views

### Method for interpolation between 3+ quaternions?

I'm currently using spherical linear interpolation (slerp) to interpolate between two quaterions with a weighted value. But, I'm having a difficult time coming up with a method to interpolate between ...
362 views

### Defining an OpenGL unit

I have read that you can define your OpenGL unit by using glViewport. As far as I understood if you use something like glViewport(0,0,600,600) then 1 OpenGL unit = 600 pixels. Now my problem is what ...
350 views

Short version: What can happen to the output of a vertex shader that leads to no(or very few) pixels being drawn, especially in relation to a perspective matrix. Long version: My problem refers to ...
316 views

### Orbiting multiple objects evenly around a changing radius

I have multiple objects (circles) and I want to place them in a circle, with even distance between each one, and have them orbit the center of the screen. If I remove one object, I want the orbit ...
515 views

### Mathematics for Game Development Book

For someone with some background in maths, what is a good book about: The core mathematics for game development How these techniques are applied to common problems in game development In ...
205 views

### Getting an angle in degrees from north

This may have been asked already, but I was unable to find it, because I don't really know what I'm looking for. I drew a picture: I need theta. I've seen various solutions using Vector.Dot, and ...
461 views

### deferred rendering and point light radius

I use a common attenuation equation for point lights: attenuation = 1 / kc + kl * d + kq * d^2. I use deferred rendering so I need to know a light radius. An example light has following intensity: ...