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

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 can I make my score-based game addictive?

I need some ideas to make players interested in the game result. Otherwise, the player plays again to get high score. My game is a calculation game that measures the speed of calculations that the ...
298 views

### D3DXMatrixDecompose gives different quaternion than D3DXQuaternionRotationMatrix

In trying to solve this problem, I tracked down the problem to the conversion of the rotation matrix to quaternion. In particular, consider the following matrix: -0.02099178 0.9997436 -0.008475631 0 ...
88 views

### Opengl 3.2 Flickering after smooth animation?

Okay I am new to OpenGL I am getting an odd issue. I am performing rotation on a bunch of triangles on a scene graph. The rotation starts off really smooth everything is animating then much later you ...
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. ...
210 views

### Matrix represents same rotation with different euler angles

I have Transform component storing it's rotation as Quaternion. Transform has set/getEulerAngles (rotation order oy, ox, oz). I want to rotate object in any direction but while testing I get ...
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 ...
194 views

### Heightmap implementation in javascript question, a 2D water heightmap

I have a height map function from GPU Gems 2 Chapter 18, where they're generating a set of B/W pixels from this equation: H(x,y,t) = Σi=0N h ( Axi x + Bxi,  Ayi y + Byi,  Ati x + ...
573 views

### Quaternion Look At with Up vector

I have implemented a "look at" method for my screen elements and it almost works how I want it to work. The ScreenElement class uses a R3 Vector and a Quaternion to determine the position and ...
536 views

### Picking 3D with OpenGL ES 2

I'm trying to implement picking in my framework but I don't understand how I can do this. I'm working with: OpenGL ES 2. GLM mathematic library. What I have understand, picking can be made with ...
92 views

### adding space between each bricks in breakOut [closed]

i am trying to create breakout. code below loop though my 2d array(map) and creates bricks. the problem is that i want to add 10 pixels space between each bricks. i was thinking to add ...
71 views

### Different types of smooth object movement

In a game I have a specific object and two positions the object will move from and to. I already have the function for calculating current position in specific time. It works like this: Inputting 0 ...
101 views

### Should I negate a variable or use absolute value? [closed]

this is how i was chaning ball postion if(...) //if ball goes to left of screen dx = -dx if(...) //if ball goes right of screen dx = -dx; i found some people using math.abs to move ball ...
305 views

### Simulated Economic Factors Based on Supply and Demand in MMO Resource Trading Game

I'm working on a gam (naturally), and the primary activity for the player is to buy and sell commodities at various marketplaces. Each commodity has the following properties: Base Price: if all ...
115 views

### How to make healthbar size relative to hp

Like in most games with healthbars, the units in my game have a hp_bar object which is a frame, with a slightly smaller rectangle inside which should get smaller (and change color) as a unit loses hp, ...
153 views

### What kind of projection is ScreenX=X/Z, ScreenY=Y/Z?

I have an existing class which transforms 3D vectors and projects them on a 2D plane (Camera). The code is all written in C without help from an external library. To project a single vector (X,Y,Z) ...
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 ...
251 views

### Negative scale in Matrix 4x4

After some rotations and to from quaternion conversions I get negative scale from Matrix 4x4, is it possible? I need that scale to draw sprite on screen so I get sprite flipped, how to deal with this ...
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 ...
128 views

### Keeping raycast on the same level

I want my raycast to end at certain height(red line). But as the game is 3D and the camera rotates I can't use a fixed magnitude. What I thought was a stroke of genius, I figured I'd project the ...
111 views

### Rotation independent rotation

I came up with some cube rotating, but I could not make it smooth and easy to use because as the cube turned - the keys that handle the turning changed their purpose. Link to demo. The demo rotation ...
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 ...
118 views

### A controlled trapezoid transformation with perspective projecton

I'm trying to implement a controlled trapezoid transformation in Adobe Flash's ActionScript using the built-in perspective projection facility. To give you an idea of how the effect looks like: ...
56 views

### Going from point a to b through a curve using “gravity” [duplicate]

I have enemies and when they die they spawn an energy ball with a given velocity. I want to move this ball to the player using "gravity" to create a curved path. I have a version of the function but ...
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 ...
192 views

### 1D functions and shapes

I have a set of numbers I normalize ( so the converted number is between 0 and 1 ) which I want to pass trough a function, which in return gives me a different number between 0 and 1 based on the ...
133 views

### Map displacement transformation to texture space?

I am trying to displace geometry in object space without giving the appearance of texture warping. My idea is to displace the UV lookup by a relative amount to the geometry displacement. Any ...
408 views

### Fast method of detecting whether point is inside mesh

I'm trying to construct a 3d object from a large number of particles. I think this is called BVH (Bounding volume hierarchy). I figured the best way is to draw the particles inside the mesh, then let ...
240 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 ...
63 views

### Math concepts from the ground up; practical uses in game design? [duplicate]

I recently went back to school and chose to start learning math from the ground up, to ensure proper footing in higher level courses. I was always interested in game design and took a computer science ...
267 views

### Discover x,y coordinates given set arc distance and rotation

I have a turn-based car simulation. My vehicles have a maximum speed they can travel in a round, as well as a maximum amount they can change their heading over the course of a round. Say, 20 meters ...
227 views

### RGB to xyY color space conversion and luminance

The luminance calculated by following GLSL functions (fragment shaders - tonemap) has different value: float GetLuminance (vec3 rgb) { return (0.2126 * rgb.x) + (0.7152 * rgb.y) + (0.0722 * ...
551 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 ...
348 views

### Interstellar Economic Simulation

I'm designing a game reminiscent of Elite or Escape Velocity, those old space trading games, where you play a traveling merchant in space. I'd like to have the game's economy at least resemble a real ...
1k views

### Line segment and Sphere intersect

How can I check it if a line3D/ or ray is intersecting a sphere?
316 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 ...
192 views

### games logic based on closed shapes

I would like to know the math concepts behind shape based games like http://www.miniclip.com/games/fat-slice/en/ To be specific, I would like to know on how to model shapes programmatically finding ...
254 views

### Canvas isometric translations to integer coordinates

I'm creating a canvas based game with an isometric playing board. I use the following transformations to get my square tiles to render on the screen: 'applyViewportTransformation' : function() { ...
214 views

### Inventory Grid Detection

I'm working on creating an inventory system for a game. The inventory system will use cells and 2D images to represent items, like Minecraft, Diablo, or WoW. I've hit a bit of a snag when trying to ...
213 views

### Directional light and matrix issues

I'm trying to implement basic directional lightning in OpenGL 3.3 by emulating the logic shown in this guide: http://www.arcsynthesis.org/gltut/Illumination/Tutorial%2009.html I do not understand ...
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 ...
106 views

### What effect does the amount of 0 in a stat have. [closed]

Basically I want to know if the following three characters are the same character A health 10 strength 3 defence 2 character B health 100 strength 30 defence 20 character C health 1000 ...
675 views

### Getting correct angles between Vector3s

I'm working on a project where you can draw lines between points. You select one point and drag the mouse onto another point and a line is drawn between them. The line itself is a 3d object which is ...
456 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: ...
643 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 ...
705 views

### 3D isometric depth sorting

How is it possible to depth sort tiles and objects in an isometric environments without any limitations? I've been researching this for a while now and there seems to be no publicly available answers ...
122 views

### How to predict encounters between a ship and a body's sphere of influence in 2D

Long time listener, first time caller. I'm making a little hobby game in XNA, its about transport ships in space, analogous to container ships at sea. There are to be AI ships and player controlled ...
2k views

### How to extract euler angles from transformation matrix?

I have a simple realisation of entity/component game engine. Transform component have methods to set local position, local rotation, global position and global rotation. If transform is being set new ...