Mathematics questions deal with the arithmetic, geometry, calculus, formulae and other calculations used in the development of a game.

learn more… | top users | synonyms (1)

2
votes
1answer
54 views

AABB implementation

I have seen in some texts and tutorials on the web where an AABB is implemented as a position vector and then half-width and half-height vectors. What is the advantage in using the half-width and ...
1
vote
1answer
52 views

How can I test if an oriented rectangle contains another oriented rectangle?

I have the following situation: To detect whether is the red rectangle is inside orange area I use this function: - (BOOL)isTile:(CGPoint)tile insideCustomAreaMin:(CGPoint)min max:(CGPoint)max { ...
-4
votes
0answers
27 views

How start develop gambling games? [on hold]

Bello! I Hood serverside developer, experienced in high load. But I haven't any math background. Which I need learn and book readed to create correct logic for gambling games? (I want start with slot ...
0
votes
1answer
29 views

Find normal based on rotation?

Given the XYZ rotation of an object, e.g. (90,0,0), how can I find the object's normal assuming the object is pointing along it's local Z axis? In the above example the desired result is (0,1,0). ...
0
votes
0answers
28 views

Parabolic throw with set Height and range (libgdx) [duplicate]

Currently i'm working on a minigame for android where you have a rotating ball in the center of the display which jumps when touched in the direction of his current angle. I'm simply using a gravity ...
-1
votes
0answers
22 views

Isometric layer moving inside map

i'm created isometric map and now trying to limit layer moving. Main idea, that i have left bottom, right bottom, left top, right top points, that camera can not move outside, so player will not see ...
4
votes
2answers
152 views

How can I manually construct a right-handed orthographic projection matrix?

I need the formula to create a orthographic projection matrix. I am using GLM math libary and DirectX11. The reason I cannot use GLM to create it is because the NDC spaces are different between DX11 ...
0
votes
2answers
30 views

Converting A 3D Rotational Vector Into A 3D Forward Heading Vector

I need to do a raycast which accepts a Vector3D StartPos and a Vector3D EndPos. I have available to me the characters position and the cameras rotation in 3D vectors. I need to somehow compute a ...
-1
votes
0answers
66 views

best app store owner, which deals with payoneer, to host and sell an XNA game [duplicate]

I have developped a XNA game, and I'd like to sell it. I'd like to know what is the best free way to put the game as online appstore ? I need an app store owner, which deals with payoneer Thank you ...
-1
votes
4answers
83 views

Shooting based off mouse position [duplicate]

I'm trying to shoot bullets where the mouse is aiming using one image as a test. I'm trying to get the mechanics like this I have some kind of algorithm to handle that but the results arn't too ...
0
votes
0answers
33 views

Calculating co-ordinates of a line/ray that's increasing in height with a known slope/radians. Height increase is also known

basically in my game I'm firing a line. The line's anchor point is at the very bottom of it, and half of its width. When I fire the line, its rotation gets set to face where we want it to go. Then, ...
3
votes
0answers
54 views

Determining a sensible gear-like hierarchy for a series of connected objects

I would like a series of objects to behave in similar manner to a series of connected gears. This means that each black object in the diagram below will rotate at a speed based on the ratio of their ...
-1
votes
1answer
82 views

Code explanation

Can someone please explain whats going on in this code written by Paul Irish I did not understand the draw(). function draw() { var time = new Date().getTime() * 0.002; var x = Math.sin( ...
0
votes
1answer
55 views

What is the optimal way to handle matrix internal data storage for interop with native graphics apis?

I'm writing a managed (c#) game engine and have stumbled on a bit of a crossroads in design/implementation regarding matrix types. Matrix types need to be optimized for marshaling to native graphics ...
0
votes
1answer
65 views

Rotating a vector around a vector in 3D space

I am trying to rotate a moon around a planet (the planet is also rotating around an axis) but I am having trouble doing so. I tried to make the model move through space like so: @Override public ...
0
votes
2answers
45 views

Bridge made out of blocks at an angle

I'm having a bit of trouble with the math behind my project. I want the player to be able to select 2 points (vectors). With these 2 points a floor should be created. When these points are parallel to ...
0
votes
0answers
24 views

Map to Screen Coordinates for isometric style map with tile height of 71 and width of 110

I am aware of the coordinates to convert map to screen coordinates and back with isometric tiles with a height and width ratio of 2:1. What I need is the same for tile width of 110 and height of 71, I ...
0
votes
2answers
150 views

How do I create a knockback-movement?

I am a web developer new to game development, and with limited math knowledge. I am writing a character movement controller in Unity. The game has an isometric Diablo-like camera. The character moves ...
2
votes
2answers
47 views

How to use “weighted average easing” correctly with variable framerate?

I often use a weighted average for smoothly animating numerical values to a target value, like so: frame(dt) { value = ((value*someFactor) + targetValue) / (someFactor+1) } As you can see dt ...
1
vote
1answer
39 views

Fit a bounding box in the scene modifying FOV

Suppose I have a radius for a spherical bounding box around a mesh. My goal is to render the scene such as when the camera moves, the bounding box whose centre the camera look at, occupies always ...
0
votes
0answers
59 views

Closest distance from 3D point to vector line

First let's have a look at my little drawing: I have an origin point p1 defined by x, y and z co-ordinates, and a vector v given by x, y and z magnitude. I also have an arbitrary point, p2, given ...
6
votes
4answers
482 views

How do I convert from the global coordinate space to a local space?

Given an entity named EntityA, I want to define a local coordinate space, where the position of EntityA is the origin, its heading vector is the X axis, and the normal of the heading vector is the Y ...
1
vote
2answers
95 views

Find point in 3D plane

I have four points in a 3D space, example: (0,0,1) (1,0,1) (1,0,2) (0,0,2) Then I have a 2D position on that square plane: x = 0.5 y = 0.5 I need to find out the 3D space point of that position in ...
1
vote
1answer
33 views

How to find the points of intersection of two OBBs

In my game I need to be able to find the points of intersection between two OBBs. I'm using Separate Axis Theorem to check if there's an intersection and get the penetration vector if there is one. ...
0
votes
1answer
30 views

Scaling entity by screen height (simulating depth on orthographic camera)

i want my entities to be at 100% scaling (for example 128x128 pixels) when they are at 40% of the screen height (for example 480 pixels at 100%), so when they are at 41%, they are at 99% scaling ...
3
votes
1answer
263 views

Explain this line segment intersection code

I've been reading this article on pathfinding over polygon meshes using line-of-sight, and in the article are several code snippets. One of them, the one I'm trying to understand, is a simple function ...
2
votes
2answers
198 views

How to make a projectile align correctly with the entity that shot it

I'm developing a 2D game. In the game, all entities can rotate 360 degrees. Each entity holds an angle value, and every frame it is drawn rotated around it's center by it's current angle value. For ...
2
votes
2answers
211 views

How can I simplify this code to compute the shortest rotation between two angles?

The following code will find the shortest rotation (in radians) (from pi to -pi) that I need to apply to from to leave me with to. Scalar rotationBetween(Scalar from, Scalar to) { Scalar fromMod ...
1
vote
1answer
34 views

XY Location scaling with varying density screens

I have a phone with resolution H=1280,W=720,Density=2 I have a tablet with resolution H=1216,W=800,Density=1.331 I drew a rectangle on my phone with corners Left,Top (-1.6,1.55), Right,Bottom ...
1
vote
1answer
69 views

How do you change movement to strafe

Right now my player can move forward and backward using case 'a':case 'A': speed.x = lx * 0.1; speed.z = lz * 0.1; break; case 'b':case 'B': speed.x = -(lx * 0.1); speed.z = ...
1
vote
2answers
66 views

How to get the normal that points *out* of a polygon

In 2D, each vector (x, y) has two normals: (-y, x) and (y, -x), pointing in opposite directions. Say I have a polygon and for each of it's edges I need to get the normal pointing outwards. In the ...
1
vote
0answers
48 views

Resolving penentration after collision using Separating Axis Thereom

I implemented collision detection in my game using SAT. The detection works, but I'm trying to use the algorithm to figure out the penetration vector of the two OBBs and push them apart (before doing ...
3
votes
1answer
87 views

How can I find the tangent and normal at an interpolated point on a Catmull-Rom/Hermite spline?

I have an implementation of a simple Catmull-Rom spline. It works, but I'm trying my hardest to be able to place vertices at extrusions along the curve. For this I need the normal (and tangent in the ...
20
votes
3answers
2k views

Are there 3D projections other than orthographic and perspective? [closed]

The question is pretty much in the title. Are there notable 3D projections other than orthographic and perspective that could be used in a 3D system such as OpenGL? In particular, are there any that ...
3
votes
1answer
60 views

Make an object follow the mouse pointer with LÖVE2D

I've been trying to make a picture follow the mouse pointer with LÖVE2D. I want that the object follow the mouse, and not just be the mouse coordinates, I did that. So I toked the distance between ...
1
vote
1answer
75 views

Predicted target location [duplicate]

I'm having an issue with calculating the predicted linear angle a projectile needs to move in to intersect a moving enemy ship for my 2D game. I've tried following the document here, but what I've ...
1
vote
1answer
31 views

Predicted target location

I'm having an issue with calculating the predicted linear angle a projectile needs to move in to intersect a moving enemy ship for my 2D game. I've tried following the document here, but what I've ...
0
votes
0answers
40 views

Equation / formula to determine an objects position on an ellipitcal path

I'm making a space game, as such I need objects to follow an elliptical path (orbit). I've worked out how to calculate all the important aspects of my orbits, the only remaining thing is how to have ...
2
votes
2answers
142 views

How can I simulate the sun's position for 3D lighting?

I'm using a directional light as a light source. It dosn't have a positon, only a direction, represented by a vec3. I'm trying to figure out how to make the light direction to simulate sun movement ...
0
votes
2answers
53 views

Convert vector interpolation to quaternion interpolation? (Catmull-Rom)

I have some existing code which does catmull-rom interpolation on two vectors (facing and up). I'm converting this to use quaternions instead (to replace the two vectors). Is there a general way to ...
0
votes
0answers
92 views

Sun & Moon Movement

I'm creating a 2D HTML5 Canvas Game and am stuck on how to go about animating my Sun & Moon. The current setup is basically setting the moon at -1024 on the X-axis and the sun at 0 and animating ...
0
votes
0answers
62 views

Using Bullet physics engine to find the moment of object contact before penetration

I would like to use Bullet Physics engine to simulate the objects in 3D world. One of the objects in the world will move using the position from 3D mouse control. I will call it "Mouse Object" and ...
0
votes
1answer
75 views

Implementing Camera Zoom in a 2D Engine

I'm currently trying to implement camera scaling/zoom in my 2D Engine. Normally I calculate the Sprite's drawing size and position similar to this pseudo code: render() { var x = sprite.x; ...
2
votes
2answers
145 views

How do I convert screen coordinates to between -1 and 1?

I'm writing a function that allows me to click on my tiles. The origin for my tiles is the center, however, the mouse's origin is the top left. I need a way to transform my mouse coordinates into my ...
34
votes
3answers
7k views

Why do we use the Pythagorean theorem in game physics?

I've recently learned that we use Pythagorean theorem a lot in our physics calculations and I'm afraid I don't really get the point. Here's an example from a book to make sure an object doesn't ...
3
votes
1answer
152 views

Most efficient way to implement delta time

Here's one way to implement delta time: /// init /// var duration = 5000, currentTime = Date.now(); // and create cube, scene, camera ect ////// function animate() { /// determine delta /// ...
4
votes
2answers
1k views

Why isn't this physics code scaling velocities separately?

I'm working my way through this book and I'm trying to work this code out: var squaredVelocity = this.velocity.x*this.velocity.x + this.velocity.z*this.velocity.z; if ...
3
votes
0answers
85 views

Learning game and effect related mathematical tricks [closed]

I'm trying to learn how to code some "effects" more succinctly. For example, I have sprite clouds in my game, and their transparency is determined with the following formula on their update-method, ...
2
votes
1answer
33 views

Can I use quaternions and do a partial multiplication?

I have some code that rotates an object around an axis. It does this by creating a quaternion for a rotation and then multiplying by the old orientation: nextRot = QuaternionRotationAxis( axis, ...
7
votes
3answers
392 views

How can I compare two quaternions for logical equality?

I'm trying to write some unit tests and realize I don't know how to compare quaternions. I need to know if two quaternions represent the same orientation (the object would be facing the same way). ...