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

350 views

### Detect mouse click on a bezier curve's neighborhood

I'm developing a game in HTML5 and JavaScript using Canvas API for drawing graphics. I want to detect if the user has clicked on a bezier curve which has the line width of 20 pixels (something like ...
156 views

### Determine inventory item position shape

Not a great title but couldnt think of a shorter way to describe it. I am trying to think of the best way to determine the shape of items placed in the players inventory. I guess the best examples ...
369 views

### Aligning bullet's position in Asteroid Game

I'm writing an asteroid game and I would like to align the bullets on the ship's tip. I also want when the ship fires, the bullet gets the same orientation(angle, direction) of the ship and also be ...
736 views

### How to convert a number from one min\max set to another min\max set?

I'm doing terrain generation and I have a perlin library that is giving me random numbers between -1 and +1. I want to convert this to the scale of 0-255. What is the proper way to do this?
749 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 ...
438 views

### Convert point to its barymetric coordinates

I'm making a 2.5D game engine (in JavaScript) and I'm trying to get it to detect whether a block is under the cursor. This would be a simple task were it restricted to single-level isometric ...
202 views

### Determining my playable area/field of view

Contrary to what I found searching for the answer, I'm not trying to see whether a character is in view of another character. What I need to find out is the size of the field of view. This is because ...
466 views

### Asteroids Ship Movement

I have read source code of asteroids game. I want to know why when updating the ship's position in X, and Y Axis, we must write it in sin and cosine of the current angle. Is it angular velocity ? why ...
1k views

### How can I snap a game object's position to a grid?

I'm making a game that involves "falling block" gameplay elements. The problem is, I'm not quite sure how to make it so that the blocks will snap to some kind of grid, in other words, I'm not sure how ...
296 views

### Inverting matrix then decomposing gives different quaternion than decomposing then inverting the quat

I'm getting different signs when I convert a matrix to quaternion and invert that, versus when I invert a matrix and then get the quaternion from it: Quaternion a = Quaternion.Invert(getRotation(m)); ...
340 views

### How should I learn about collision detection?

If I want to use physics engine for my game then how should I go to learn collision-detection algorithms? When I read AI book for games, the book talks about collision detection, so I want to learn ...
214 views

### How can I determine the direction of turn?

I want a function that gives me the turn direction for my object (1 or -1) I have two angles 1 - current rotation(A) 0 <= A <= 360 2 - target rotation(B) 0 <= B <= 360 int turnSide ...
184 views

### Electricity and Magnetism: Relevant?

The computer science major at my university requires that I take a sequence in either biology, chemistry, and physics, plus an additional natural science course (which I might fill with meteorology). ...
349 views

### Blending colors on Surfaces in PyGame?

So I'm making a game in Python and PyGame. I have aliens and blocks that each adopt one of several colors; rather than make several copies of them in different colors, I plan on making the sprite ...
653 views

### Create acceleration with direction

I want to move my object with an acceleration in the proper direction. I'm not good at math so I need some help. The example in Game Maker is: friction = 0.3; direction = 180; speed = 5; But I'm ...
186 views

### Web sites with famous game information? [closed]

Is there any website containing informations related with some famous game? For information I mean how to calculate damage in a rpg for example, or how they've set camera and other tips like this! ...
681 views

### Rotating a polygon around it's center

I have drawn a ship using three lines, and would like to rotate the ship around its axis in opengl, I have tried the following, but the ship translates while rotation!. void Ship::Draw( ) { ...
150 views

### Help understanding the order of vector subtraction

I always struggle with intuitively figuring out the order of subtraction in multiple situations for example The difference between the current mouse coordinates and the last frame's coordinates The ...
329 views

### Rotation matrices from Quaternion.Identity and -Quaternion.Identity are the same?

If I create a rotation matrix from an identity quaternion then it is the same as a creating it from a negative identity quaternion Matrix m0 = ...
384 views

### Implementing framerate independence

I know the following line of code has the effect of moving 3 units per milliseconds independent of framerate, but my sucky mathematical intuition is unable to understand WHY this works translation *= ...
319 views

### Find the nearest control points either side of a Catmull Rom spline segment

There is a formula for evaluating a Catmull Rom spline segment at time 't' found here. The problem with this is that it requires finding the two control points either side of the segment to evaluate. ...
204 views

### Question about Target parameter of Matrix.CreateLookAt

I have a newbie question that's causing me a little bit of confusion when experimenting with cameras and reading other peoples implementations - does this parameter represent a point or a vector? In ...
293 views

### Optimizing hierarchical transform

I'm transforming objects in 3D space by transforming each vector with the object's 4x4 transform matrix. In order to achieve hierarchical transform, I transform the child by its own matrix, and then ...
383 views

### 3D Vector “End Point” Calculation for procedural Vector Graphics

Alright, So I need some help with some Vector Math. I've developing some game Engines that have Procedural Fractal Generation for Some Graphics, such as using Lindenmayer Systems for generating Trees ...
341 views

### Finding closest object to a location within a specific perpendicular distance to direction vector

I have a location and a direction vector indicating facing, I want to find the closest object to that location that is within some tolerance distance (perpendicular distance) to the ray formed by the ...
789 views

### Checking for collisions on a 3D heightmap

I have a 3D heightmap drawn using OpenGL (which isn't important). It's represented by a 2D array of height data. To draw this I go through the array using each point as a vertex. Three vertices are ...
215 views

### Matrices: Arrays or separate member variables?

I'm teaching myself 3D maths and in the process building my own rudimentary engine (of sorts). I was wondering what would be the best way to structure my matrix class. There are a few options: ...
175 views

### Game speed cubic growth

Is it possible, using delta in my update method to increase a game speed variable exponentially on cubic growth (the blue line below) My maths isn't great so I'm not sure how the formula would be ...
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 ...
331 views

### Adding tolerance to a point in polygon test

I've been using this method which was taken from Game Coding Complete to detect whether a point is inside of a polygon. It works in almost every case, but is failing on a few edge cases, and I can't ...
556 views

### Game Institute Math Courses

I'm 21 years old and I suck at math, I mean really bad. I don't have the necessary logic to apply it towards programming. I would like to learn the math and logic of applying it. I found Game ...
429 views

### Is it possible to procedurally place objects in a non-gridded game?

I'd like to implement procedural world generation, but I don't want it to look gridded or blocky, where everything is obviously placed on an integer grid. I know that you can do this in gridded ...
174 views

### Math major as a viable degree [closed]

While I realize there are many topics about CS vs software engineering vs game school programs, I haven't found anything relating to whether pure math degrees (with CS minor and electives) would also ...
944 views

### as3 3D camera lookat

I'm making a 3D camera scene in Flash, draw using drawTriangles() and rotated and translated using a Matrix3D. I've got the camera to look after a specific point, but only on the Y-axis, using the x ...
670 views

### When to use Euler vs Axis angles vs Quaternions?

I understand the theory behind each but I was wondering if people could share their experiences in when one would use one over the other For instance, if you were implementing a chase camera, a ...
241 views

### Why does multiplying texture coordinates scale the texture?

I'm having trouble visualizing this geometrically - why is it that multiplying the U,V coordinates of a texture coordinate has the effect of scaling that texture by that factor? eg if you scaled the ...
179 views

### Camera not working

I made a camera in DX9. To move forward I press the Up arrow. To rotate on the Y axis I use the mouse. When I perform these movements on their own the camera moves at the speed I want. However, if I ...
150 views

### Get all triangles that are < N dist from you?

Does anyone know of a way I could add a radius to this code for p? Like basically saying "this is true if the triangle is < N dist from the point" public boolean isPointInTriangle( Vector3f p, ...
195 views

### How to balance this Pokémon simulator metagame by feedback?

This is a Pokémon simulator where you build a team of 6 pokémon and battle with someone. Unfortunately, some Pokémon are stronger than others and only a few of the hundredth species are practical. 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 ...
286 views

### Transform 3D vectors between coordinate systems

I've got 6 points in 3D space: A,B,C,D,E,F, that represent 4 vectors. AB is perpendicular to AC and DE is perpendicular to DF. I need to find a transformation matrix M, that transforms AB to DE and ...
335 views

### Estimate angle to launch missile, maths question

I've been working on this for an hour or two now and my maths really isn't my strong suit which is definitely not a good thing for a game programmer but that shouldn't stop me enjoying a hobby surely? ...
367 views

### Smoothing rotation

I've spent the last three days trying to work out how to rotate a sprite smoothly depending on the velocity.x value of the sprite. I'm using this: float Proportion = 9.5; float maxDiff = 200; float ...
326 views

### Elliptical orbit modeling

I'm playing with orbits in a simple 2-d game where a ship flies around in space and is attracted to massive things. The ship's velocity is stored in a vector and acceleration is applied to it every ...
249 views

### how to transform child elements position into a world position

I'm making a 2d space game in Javascript with canvas. In this game there's a bunch of spaceships, positioned in world space, with turrets, positioned relative to their parent ships. These objects also ...
343 views

### Position Reconstruction from Depth by inverting Perspective Projection

I had some trouble reconstructing position from depth sampled from the depth buffer. I use the equivalent of gluPerspective in GLM. The code in GLM is: template GLM_FUNC_QUALIFIER detail::tmat4x4 ...
826 views

### Interpolation between two 3D points?

I'm working with some splines which define a path a character follows (you can see a gameplay video here to get a better understanding of what's going on: http://www.youtube.com/watch?v=BndobjOiZ6g). ...
349 views

### How do I convert sin, cos and tan into an int in Java?

How would you be able to change Math.sin, Math.cos and Math.tan into an int? This is because I heard that it is useful to have those Math resources in movement, gravity, etc. in gaming. Also, as a ...