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.
2
votes
3answers
2k views
Getting isometric grid coordinates from standard X,Y coordinates
I'm currently trying to add sprites to an isometric Tiled TMX map using Objects in cocos2d. The problem is the X and Y metadata from TMX object are in standard 2d format (pixels x, pixels y), instead ...
1
vote
0answers
92 views
Numerically stable(ish) method of getting Y-intercept of mouse position?
I'm trying to unproject the mouse position to get the position on the X-Z plane of a ray cast from the mouse. The camera is fully controllable by the user. Right now, the algorithm I'm using is...
...
3
votes
1answer
278 views
Spherical to Cartesian Coordinates
Well I'm reading the Frank's Luna DirectX10 book and, while I'm trying to understand the first demo, I found something that's not very clear at least for me. In the updateScene method, when I press A, ...
1
vote
2answers
685 views
Line Intersection from parametric equation
I'm sure this question has been asked before. However, I'm trying to connect the dots by translating an equation on paper into an actual function. I thought It would be interesting to ask here instead ...
6
votes
4answers
2k views
Calculating velocity needed to hit target in parabolic arc
If I have a point which I want to hit at the end or during a parabolic arc, how would I calculate the needed x and y velocity?
12
votes
1answer
206 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 ...
0
votes
1answer
110 views
Build a view frustum from angles
I have 4 angles, left, right, top & bottom. These angles are in degrees. They define the angle between the forward vector and the corresponding side. I am trying to use these to calculate the ...
0
votes
1answer
108 views
Rotate/Translate object in local space
I am just trying to create a movementcontroller class for game entities. These class should transform the entity affected by the mouse and keyboard input. I am able to calculate the changed rotation ...
4
votes
1answer
122 views
How to transform mesh components?
I am attempting to transform the components of a mesh directly using a 4x4 matrix. This is working for the vertex positions, but it is not working for the normals (and probably not the tangents ...
-2
votes
1answer
161 views
Move projectile in direction the gun is facing [duplicate]
Possible Duplicate:
Move sprite in the direction it is facing?
I am attempting to have a projectile follow the direction a gun is facing. When using the following code I am unable to make ...
1
vote
1answer
847 views
Optimized algorithm for line-sphere intersection in GLSL
Well, hello then!
I need to find intersection between line and sphere in GLSL. Right now my solution is based on Paul Bourke's page and was ported to GLSL this way:
// The line passes through p1 and ...
0
votes
1answer
98 views
Using NumPy arrays as 2D mathematical vectors?
Right now I'm using lists as position, velocity, and acceleration vectors in my game. Is that a better option than using NumPy's arrays (not the standard library's) as vectors (with float data ...
15
votes
7answers
527 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 = ...
5
votes
1answer
493 views
Re-create 2D side-on wave effect from Worms game
I'm trying to recreate the waves/water effect from Worms ( see here http://youtu.be/S6lrRqst9Z4?t=31s ) From what I understand its not actually a sprite, its procedurally generated by something like a ...
1
vote
2answers
97 views
Logarithmic spacing of FFT subbands
I'm trying to do the examples within the GameDev.net Beat Detection article ( http://archive.gamedev.net/archive/reference/programming/features/beatdetection/index.html ) I have no issue with ...
3
votes
1answer
243 views
Understanding normal maps on terrain
I'm having trouble understanding some of the math behind normal map textures even though I've got it to work using borrowed code, I want to understand it.
I have a terrain based on a heightmap. I'm ...
1
vote
2answers
122 views
Determining if something is on the right or left side of an object?
I have a character in a 3D world which is facing an arbitrary direction on a flat plane, the player can click on the left or right side of the character and based on which side is clicked on a ...
0
votes
1answer
157 views
Tilting towards turn direction (for a motorbike)
I have a motorbike which moves along based on a direction vector, I set its forward direction to the direction it's moving.
What I'd like to also do with it is have the motorcycle tilt in the ...
5
votes
2answers
363 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. ...
6
votes
3answers
503 views
Can a straight line be called a polygon?
According to the definition of Polygon, If a Poly-line's first and last points are connected then it is called Polygon. See the image below. I have P1, .... P5 Polyline. If I draw a line from P5 to ...
16
votes
2answers
578 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?
0
votes
0answers
59 views
Calculating the position of an object with regards to current position using OpenGL like matrices
i have a 1st person camera that collides with walls, i also have a small sphere in front of my camera denoted by the camera position plus the distance ahead. I cannot get the postion of the sphere but ...
2
votes
2answers
381 views
Quaternion based rotation and pivot position
I can't figure out how to perform matrix rotation using Quaternion while taking into account pivot position in OpenGL.What I am currently getting is rotation of the object around some point in the ...
-1
votes
2answers
179 views
What kind of math should I be expecting in advanced programming? [duplicate]
Possible Duplicate:
What math should all game programmers know?
And I don't mean just space shooters and such, because in non-3D environments it's obvious that not much beyond elementary ...
2
votes
0answers
136 views
Portal View/Projection Matrix near plane
For RenderToTexture/Camera based portal rendering, the basics seems simple enough.
However, with a free camera, most of the time it is going to be looking at such portals at an angle:
Now a ...
11
votes
5answers
1k 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 ...
4
votes
3answers
252 views
How to get distance from point to line with distinction between side of line?
I'm making a 2d racing game. I'm taking the nice standard approach of having a set of points defining the center of the track and detecting whether the car is off the track by detecting its distance ...
39
votes
4answers
792 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 ...
0
votes
1answer
127 views
Characteristics, what's the inverse of (x*(x+1))/2? [closed]
In my game you can spend points to upgrade characteristics. Each characteristic has a formula like:
A) out = in :
for one point spent, one pont gained (you spend 1 point on Force so your force goes ...
5
votes
1answer
347 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 ...
2
votes
2answers
105 views
setting the position in different resolution
I have a normal game window which is 640*480, and everything is fine, but when I try to maximize the window, the objects translate to different positions on the screen, for example If I have a circle ...
2
votes
0answers
102 views
Initial direction of intersection between two moving vehicles? [duplicate]
Possible Duplicate:
Predicting enemy position in order to have an object lead its target
I'm working with a bit of projectile prediction for my AI and I'm looking for some ideas, any input?
...
0
votes
1answer
69 views
Vector transform equation explanation
I'm trying to understand the maths of moving points in a 3d space by making a game written in C#.
I'm looking at this wolfire blog series which explains some basic 3d maths. I've read the first two ...
3
votes
3answers
317 views
How do I approach this collision model?
This is the game level prototype I have already implemented. It has few objects per room to allow me to finally add some collision detection/response code into it.
VIDEO
As you can probably see, ...
1
vote
2answers
98 views
How do I apply a force using the object direction and speed?
I have a 3D object moving and I need to be able to apply forces to it such as gravity. In 2D, I would simply store its movement in dx and dy, but since this is in 3D, I am using a Vector3D direction ...
1
vote
2answers
230 views
Confusion about Rotation matrices from Euler Angles
I am trying to learn more about Euler Angles so as to help myself in understanding how I can control my camera better in the game.
I came across the following formula that converts Euler Angles to ...
1
vote
1answer
199 views
How to get a point to the left/right of a vector
I have a position vector of a point in space and a quaternion for it's rotation. What i'm trying to calculate is a point too the left and a point to the right.
I have the position and ...
6
votes
1answer
558 views
Why doesn't Unity's OnCollisionEnter give me surface normals, and what's the most reliable way to get them?
Unity's on collision event gives you a Collision object that gives you some information about the collision that happened (including a list of ContactPoints with hit normals).
But what you don't get ...
5
votes
3answers
847 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 ...
2
votes
2answers
1k views
Rotate sphere in Javascript / three.js while moving along x/z plane
I have a sphere/ball in three.js which I want to "roll" around on the x/z plane. For the z axis I could simply do this no matter what the current x and y rotation is:
sphere.roll_z = ...
3
votes
2answers
315 views
3D rotation matrices deform object while rotating
I'm writing a small 3D renderer (using an orthographic projection right now).
I've run into some trouble with my 3D rotation matrices. They seem to squeeze my 3D object (a box primitive) at certain ...
0
votes
1answer
412 views
Building View Matrix in Direct3D11
Am I doing it right? I converted this.
m_ViewMatrix = XMMatrixLookAtLH(XMLoadFloat3(&m_Position), lookAtVector, upVector);
to this one.
XMVECTOR vz = XMVector3Normalize( lookAtVector - ...
1
vote
1answer
223 views
Recreating Doodle Jump in Canvas - Platforms spawning out of reach
I have started to recreate Doodle Jump in HTML using Canvas. Here's my current progress. As you can see, if you play it for a few seconds, some platforms will be out of the player's reach. I don't ...
2
votes
3answers
194 views
How to adjust position relative to resolutions?
I have a lot of objects on the screen and would like at different resolutions, object's positions rendered correctly on the screen irrespective of the resolution. Is it correct to multiply the ...
1
vote
2answers
154 views
Billboarding + aligning with velocity direction
I'm working on a particle system where I'm orientating the billboard using the inverted orientation matrix of my camera. This works quite well and my quad are rotated correctly towards the camera.
...
3
votes
2answers
145 views
how to calculate intersection time and place of multiple moving arcs
I have rocks orbiting moons, moons orbiting planets, planets orbiting suns, and suns orbiting black holes, and the current system could have many many layers of orbitage.
the position of any object ...
1
vote
2answers
107 views
ricocheting off a wall
I have a capsule (sphere sweep) that I've computed the collision on a mesh with.
I know the point of impact and normal of the face it collides with.
My moving object - I'm using a capsule to ...
1
vote
3answers
303 views
(int) Math.floor(x / TILESIZE) or just (int) (x / TILESIZE)
I have a Array that stores my map data and my Tiles are 64X64. Sometimes I need to convert from pixels to units of tiles. So I was doing:
int x
int y
public void myFunction()
{
getTile((int) ...
2
votes
2answers
266 views
Rotating a child shape relative to its parent's orientation
When rotating a shape using a quaternion value I also wish rotate its child shape.
The parent and child shapes both start with different orientations but their relative orientations should always be ...
1
vote
3answers
468 views
Get intersection of vector in the middle of the screen
My screen resolution is 640x480 and I have two Vector2 objects located at (10,10) and (600, 320).
How can I connect these two objects and extend the line to encompass the whole screens width, how can ...
