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.
3
votes
2answers
88 views
What's a pre-multiplied 4x4 matrix?
I'm using a 3d game engine, that uses a 4x4 matrix to modify the camera projection.
The matrix is in the regular 4x4 format:
r r r x
r r r y
r r r z
- - - zoom
The description for the ...
3
votes
1answer
136 views
What is a good way to determine if a vector is between two other vectors?
I could operate with the angles, but I do not have the angles calculated yet (and would like to avoid having to do that). It would be possible to calculate and cache the local-coordinate-frame angles, ...
2
votes
1answer
125 views
Formula to calculate the changes in the fortunes of a stock based on how many shares are bought or sold
I am creating a stock market simulator for an event in my college. Supposing I have 20 companies in it all starting with a common base price, I need a formula to calculate the changes in the fortunes ...
2
votes
3answers
52 views
How to get translation from view matrix
How can I retrieve the camera's world-space position from its view matrix?
The only answers I've seen to this question suggest the translation is in the last row/col but this wouldn't work since the ...
7
votes
1answer
240 views
Helicopter game, but waves?
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 wall-generation engine.
Any pointers into ...
2
votes
1answer
200 views
Understanding log/exp formula for RPG experience
While looking for examples of RPG experience formulas I came across this one
How to create adjustable formula for RPG level up requirements?, and I would really like to figure it out because I don't ...
9
votes
2answers
257 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 ...
2
votes
2answers
64 views
Suggest a simple Java math library for matrix operations for use with OpenGL (lwjgl)
I'm writing an OpenGL app with Java. I need to do some math for camera and frustum culling (for AABB). Could you suggest a simple and fast Java math library for that?
2
votes
4answers
124 views
How to detect if object is moving in clockwise- or counterclockwise direction?
I've read this one, but I need more info: rotating an object from sourceAngle to destAngle, both 0-359, clockwise or counter clockwise?
I have a ball. The user is able to drag the ball in any ...
1
vote
2answers
132 views
Should SIMD be used by people who are new to game development?
I have been learning game development, using C++ and OpenGL, for about 4-5 months. Before that I used to program in C# and the .NET platform(about a year). So, I consider myself new to game ...
8
votes
2answers
225 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 ...
7
votes
2answers
134 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 ...
2
votes
2answers
233 views
Dot Product Vs Cross Product Turning a Turret Towards A Enemy and firing
http://pastebin.com/iw9DHf7s is code demonstrating dot product turning a turretto a target and firing. It works and chooses best angle to spin.
A problem can occur when game goes faster (better ...
0
votes
0answers
63 views
Opengl-es picking object
I saw a lot of picking code opengl-es, but nothing worked. Can someone give me what am I missing?
My code is (from tutorials/forums)
Vec3 far = Camera.getPosition();
Vec3 near = ...
3
votes
4answers
180 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 ...
-1
votes
1answer
77 views
How to implement cue-stick animation for a pool game?
Hello I am developing a Pool game, and I've been scratching my head about what formula is needed to implement an animation for the cue stick.
The animation of the cue stick should look as if it's ...
0
votes
2answers
128 views
Moving along a flat plane with accordance to camera view
I'm making a 3D game, and I'm stuck on a little experiment.
I currently have a flat plane with a free camera running around, and a sphere (really, a light approximated as a sphere) that rests above ...
6
votes
2answers
118 views
How do you calculate if a line is facing a curve?
Given the 2 points describing a line segment, and the 3 points describing a quadratic bezier curve, how do you calculate if the line is facing towards or away from the curve?
The line has a fixed ...
3
votes
1answer
86 views
How do you triangulate a 3D point from a pair of stereo images?
I'm working with a stereo pair of photos, and trying to obtain a set of 3D points from matching points on these 2 images. How exactly is the point triangulated? Do you throw a ray from the camera ...
4
votes
6answers
256 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 ...
5
votes
1answer
85 views
What is the point of this hard-coded vector when calculating luminance in glow/bloom effects?
I have looked at two different vertex shaders that calculate luminance and both use a "magic" vector that I'm not sure the meaning of the the actual values. For instance:
const mediump vec3 ...
0
votes
1answer
61 views
Finding the angle of a line given 2 other lines
I'm trying to implement some 2D vehicle physics. For this to work I have 2 wheels attached to the body of the car. After doing some collisions checks I place the wheels at their new position. Say the ...
2
votes
4answers
192 views
What is an efficient 2D line-segment-versus-triangle intersection test?
In a 2D plane, I have a line segment (P0 and P1) and a triangle, defined by three points (t0, t1 and t2).
My goal is to test, as efficiently as possible ( in terms of computational time), whether the ...
13
votes
3answers
165 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?
8
votes
2answers
198 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.
0
votes
0answers
32 views
Matrix for positionning shadowmap on (in) screen (space)
I'm struggling with a PSSM implementation. I'm able to render the shadow maps but when I need to apply them, there is not enough slots free.
The terrain shader I'm using (for example) only has one ...
3
votes
1answer
87 views
Math behind simulating a simple light source for rotated rectangle?
Say I have a 2D Rectangle. By offsetting its position by x y and rendering a shadow by an offset, it gives the illusion of a shadow. If I rotate the rectangle Z degrees and try it with the same ...
0
votes
1answer
81 views
How can I transform a point from world space to object space?
If I have an object space described by transformation matrix that should be applied to object to transform it to world space, what I have to do to transform point (world space) to that object space.
...
1
vote
2answers
143 views
How can I orient a projectile along its flight path?
I have a projectile that is moving around the world (in a ballistics trajectory right now). I am currently keeping track of its position and velocity. I want to draw it oriented to its velocity, so ...
0
votes
2answers
280 views
Ways to define a curve
I'm trying to give shapes in my physics engine roundness/ curvature.
I am aware of various methods for mathematically defining curves; such as bezier-cruves, ellipses, etc. However I am not sure ...
2
votes
1answer
147 views
How to create projection/view matrix for hole in the monitor effect
Lets say I have my XNA app window that is sized at 640 x 480 pixels. Now lets say I have a cube model with its poly's facing in to make a room. This cube is sized 640 units wide by 480 units high by ...
3
votes
2answers
143 views
How to achieve hologram projection effect with head tracking
I want to recreate this:
http://www.youtube.com/watch?v=9xMSGmjOZIg&feature=related
I can take care of tracking the user's head, and in one of the comments I believe the author says that he used ...
2
votes
1answer
110 views
How do I build a matrix to translate one set of points to another?
I've got 3 points in space that define a triangle. I've also got a vertex buffer made up of three vertices, that also represent a triangle that I will refer to as a "model".
How can I can I find the ...
9
votes
1answer
107 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, ...
2
votes
1answer
124 views
Moving two objects proportionally
I'm trying to move two objects away from each other at a proportional distance, but on different scales. I'm not quite sure how to do this. Object A can go from position 0.1 to 1. Object B has no ...
1
vote
2answers
136 views
Converting from different handedness coordinate systems
I am currently porting a demo from XNA to DirectX which, as I understand it, both have coordinate systems with different handednesses.
What are the things I need to bare in mind when converting ...
9
votes
4answers
237 views
How do I get AI Agents to move along a curve?
Currently my very basic AI framework has agents that move along a a jagged path made up of a series of points.
They do this by simply moving their position from one point to the next. When they ...
6
votes
5answers
344 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 ...
2
votes
1answer
91 views
Make an object slide around an obstacle
I have path areas set up in a game I'm making for canvas/html5 and have got it working to keep the player within these areas. I have a function isOut(boundary, x, y) that returns true if the point is ...
0
votes
2answers
132 views
Check if an object is facing another based on angles
I already have something that calculates the bearing angle to get one object to face another. You give it the positions and it returns the angle to get one to face the other.
Now I need to figure out ...
1
vote
3answers
178 views
Find Point with only angle and distance
I'm working on a school project and we have to create a tank team with the programming game Robocode (tank battle with self programmed bots in Java).
I have to program a scout bot that scans, finds ...
4
votes
1answer
141 views
UVW: better explanation, and how to implement with GLES texture2D()
UVW texture coordinates, as opposed to UV texture coordinates, do not get very adequate explanation on the web. Many people offer the simple exlanation, "UV is for 2-dimensional textures and UVW are ...
18
votes
5answers
699 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:" ...
0
votes
1answer
50 views
How can I draw a line rotated some number of degrees away from an original line?
I have a line ahead of my moving object to serve as a raycast and its aligned with the object's movement direction. But I want also some extra lines according to an angle related to the 'head' of the ...
3
votes
4answers
195 views
How to draw a line of a given length towards a given object?
I wanna draw a line between two moving objects
I can't use:
cDrawLine(startPointCG, endPointCG);
because the line must have a length. So I'm trying to measure the angle between those two points ...
8
votes
2answers
361 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, ...
4
votes
1answer
229 views
Simplified math formula to calculate stock price based on supply/demand
I am making an overly simplified version of a stock simulator game, because I:
am fascinated with how the stock market works
learn better & faster from a project like this, rather than ...
4
votes
2answers
213 views
Ara matrices calculated on the GPU or on the CPU? Would built-in matrix functions be faster than my custom ones?
If I add a math library (for example containing a Matrix class) and use it in my program drawing with OpenGL, will my be work slower than if I used standard OpenGL functions for matrix calculations? ...
3
votes
4answers
232 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 ...
2
votes
1answer
102 views
3D Flight Path Generation and applying a curve to x,y,z
I made a little critter that roams around.
var boundary = 10.0;
var startingPoint = <0.0,0.0>
var destination = ...