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)

0
votes
2answers
50 views

(Efficiently) Generate Unique Random Numbers [duplicate]

Sorry my terminology is somewhat limited so I'll have to use more words to explain what I mean. In games that require critical hits, I've heard it's not good to generate a random number but instead ...
1
vote
3answers
93 views

Detect if two objects are going to crash

i am working on a car game where i am to create an AI, in the game there are other cars and a few objects moving around that i do not want to crash with, i have the speed, position and direction of ...
0
votes
0answers
39 views

how to calculate time to have daily gift in browser game online? [on hold]

same tittle, I'm having a bit of trouble developing code for browser game online with daily gift for players. If players login, they have a gift, next day they wont, they lost a gift. I have some ...
1
vote
3answers
94 views

Calculate intersect point / aim point

I'm working on a simple game, and I need to calculate the position to aim. Since my math days are a bit behind me, I put together a simple example to illustrate: So given that I know the position ...
1
vote
1answer
158 views

How do I reverse this function?

I'm working on an isometric tile rendering engine and I need to reverse a function I used to translate the Cartesian coordinates into isometric coordinates. I've already written a function for this, ...
0
votes
1answer
73 views

How to use atan2 to get the correct angle? (inside or outside angle) [duplicate]

I would like to rotate an object (white rectangle) towards another object (black rectangle). EDIT: the white rectangle (at the top) has a camera. I finally rotated the camera by 180 around the "y" ...
0
votes
0answers
13 views

2D viewport matrix World to Local coordinates

I would like to use a Matrix but it causes (or I think it does) problems with accuracy. Clearly classic float matrix causes jaggy movement/accuracy issues. The reason is that my objects have real ...
1
vote
0answers
31 views

Rotating a 3rd person camera toward a target

I have a 3rd person camera that doesn't look directly at the player but somewhere in front of him. When the user enter shooting mode, I want the camera to turn around the player to face the target. ...
2
votes
1answer
39 views

Mapping Coplanar Vertices in 3D space on to a 2D Plane

Say I have a plane specified by a normal vector and point on the plane. I want to specify a 2-D co-ordinate system that lies 'across' the plane, and then use that to find the 2-dimensional distance ...
-1
votes
1answer
89 views

Tile map optimization algorithm

I've read this artical on tilemap optimization https://www.scirra.com/blog/ashley/3/tech-blog-tilemap-tidbits and wondering what algorithm is used to achieve something like this. I'm wondering ...
1
vote
1answer
51 views

How to implement this collision detection function?

I would like to know how to implement this collision detection function, but I'm not even sure what it's called. The input shapes are 2D convex polygons, with an optional "rounding radius": imagine ...
2
votes
2answers
65 views

How to select random points within grid meeting min/max distance requirements from each other?

I have a 2D grid map that is relatively large. I'd like to pick some semi-random points all over it (say N points). The rule I want to ensure here, though, is that any selected points are at least M ...
0
votes
0answers
7 views

Find fastest rotation left or right to face an object [duplicate]

im working on a competition where i am creating an AI for a game that the host has published and made for this event, i have two commands for turning my car and that is left and right, spinning on the ...
0
votes
2answers
63 views

Fast Ray Sphere collision code

I am looking at here and while it's well organized a lot of links are broken: http://www.realtimerendering.com/intersections.html I am trying to find fast code that will give me the hit point and the ...
1
vote
1answer
186 views

Estimate the time it takes for an object to travel from point A to point B

I have an object with vec2 position, velocity, and destination with 2 variables maxspeed and acceleration. In each step, its position is calculated as follows: vec2 desiredVel = destination - ...
0
votes
2answers
49 views

Need some help with math steering behavior stopping on destination point

I have implemented a movement system based on steering behaviors: http://gamedevelopment.tutsplus.com/series/understanding-steering-behaviors--gamedev-12732 where each object has vec2 position, ...
0
votes
1answer
53 views

Simulate popularity

I'm working on a music game. It has genres like pop and rock. Different centuries have different music popularities. (Influences the sales) I thought about building an object like this: var rock = { ...
3
votes
5answers
227 views

Is there a quick way to determine if a vector is in a quadrant?

I am wondering if there is a quick easy way to determine if a given vector is in a specified quadrant. In the below image, I've define the ranges of the blue quadrants. For example, if I am given ...
-1
votes
0answers
14 views

Value grow fast at first and slow down later between range [duplicate]

I'm looking for math formula which start very quickly increase value in first few x value but later it's slow down a lot. Range x should be between <100.0; 50.0> y should be between <0; 100> So ...
0
votes
1answer
65 views

How to invert a damage formula?

I have created simple damage formula based on source percent, which return fixed percent of damage. DAMAGE_PERCENT = Exp(Log(100) * (1 - (100 - SOURCE_PERCENT) / 150) Here is the result: ...
1
vote
2answers
49 views

atan2 : inversed result? (angle 180 is on the right side, angle 0 on the left side)

the result of the angle between my touch and the middle,bottom of the screen gives me 180 when the touch is on the right side of the screen, and 0 when it is on the left. I don't understand why... ...
0
votes
1answer
30 views

How the values of h and the perpendicular had computed

How the values of h and the perpendicular had computed or taken in this answer of a previous question??? please clarify it How can I make a spline out of three points that define circular arc?
0
votes
1answer
33 views

Inline-Building a World (SRT) Matrix

Currently, to construct a world matrix, I have the following code: return FromScale(scale) * rotation.RotMatrix * FromTranslation(translation); However, this is constructing three matrices, and ...
0
votes
2answers
117 views

How to move dashes towards target?

Would you know how to create a dash line that moves towards the direction of the target, and if it collides with a wall, goes to the opposite angle? I have seen atan2 but I am not sure what it does, ...
0
votes
0answers
50 views

How to get a position from a radial distance and angles?

I have a radius and the 2 angles for northSouth and eastWest rotations in degrees. I need a Spherical position or a cartesian position (I have code translate one to the other) Where a position is ...
1
vote
0answers
36 views

Find the largest empty space inside a cube populated with a point cloud?

Lets say we have a set of points (x, y, z) where we know 0 < x < 1 (same for y and z). Now that 3d space is populated with monsters, players or what not. The points represent their location. We ...
4
votes
3answers
256 views

Why do we refer to a “model view” matrix and not a “viewprojection” matrix?

Why there is a model-view matrix, but not a view-projection matrix? A view-projection matrix would make much more sense to me, since every entity in the scene has his own position and therefore its ...
2
votes
2answers
581 views

What is the difference between an orthographic and oblique projection?

They both seem to be a parallel projection. I know that the angles of axes of viewing differ based on the type of orthographic projection (eg, an isometric projection has equal angles for all the ...
1
vote
0answers
50 views

Unintended twisting of geometry while generating a mesh?

I am creating a real time animation of tori (toruses), and I've run into a problem where at certain angles of my tori, the geometry is twisting up where it should remain straight. Here is an animated ...
0
votes
1answer
51 views

Organizing a Transform class to internally use quaternions

So, I'm interested in building a Transform class similar to the one used in Unity Engine, but in C++. My intent is for it to be user-friendly to change the position, rotation, and scale of a variable ...
0
votes
1answer
50 views

Determine if Plane is seen by Camera

If I have an arbitrary plane (center and normal) or a quad (center, normal and width and height) and a camera (frustum, projection & view matrix, etc). Then how would I go about calculating if the ...
2
votes
0answers
85 views

Understanding normal mapping

I am trying to understand the basics of normal mapping using this tutorial : http://ogldev.atspace.co.uk/www/tutorial26/tutorial26.html What I don't get there is the following equation : E1 = ( U1 - ...
0
votes
0answers
13 views

Smoothly scaling positions of GraphicsItems on a 2D GraphicsScene

I layout a bunch of nodes on a QGraphicsScene(A 2D Canvas). The nodes are basic ellipses. It works reasonably well. However I would like to know how to better size the ellipses. Currently I have a ...
0
votes
1answer
78 views

Controlling roll rotation when travelling along bezier curves [Unity3D]

I am currently working on implementing a curve implementation for use in Unity which includes an editor: The aim is to get an object to follow the path represented by the curve at a constant ...
0
votes
1answer
53 views

Affine transformation: rotate a plane parallel to another plane

I am writing a function that extrudes a 2D shape along a 3D spline, as found in 3D modeling software. I need a way of translating a set of points P so that they all lie in a new plane L (preserving ...
0
votes
1answer
43 views

How to move a car model on a plane?

I want to create a 3 dimensional car game. But i have a problem in moving a car in other directions and accelerating. I have a car model and a road model placed appropriately. To move car forward, I ...
1
vote
1answer
74 views

What is the purpose of integration in physics engines?

All online resources seem to assume that you know what this means and/or state that this is related to object movement in some way. How does this differ than just position.x++ and position.y++ and ...
0
votes
1answer
59 views

Path finding for Vector Based System

I understand that typical path algorithms are based on nodes in a graph (not tiled nodes or whatever), but i can't get my head around to find an idea how to implement a path finding algorithm for a ...
1
vote
2answers
88 views

Rotating an object towards a target on the Y axis

I am attempting to rotate a 3D object on its Y-axis towards a target it is looking at. I have always struggled with rotations so I would like to try to avoid using Unity's built in functions, i.e ...
1
vote
1answer
39 views

Finding the side of a shape a ray intersects

For some simple 3D shapes (cubes, prisms) how can I determine which side a ray intersects, knowing the direction of the ray, and the normals of the shapes' sides. I thought of using plane ...
0
votes
1answer
66 views

Calculate slope for linear interpolated movement

I want to move rectangles to their targets the "smooth" way with linear interpolation. I hope this is right. float slope(float x1, float x2, float y1, float y2) { return std::abs((y2 - y1)) / ...
0
votes
1answer
59 views

Normalizing a homogeneous 3d point

As I've seen corruption in geometry, why is it a bad idea to normalize a homogeneous (divide by w) the vertex position returned from vertex shader? Update Vertex shader: // float4 pos : ...
0
votes
1answer
89 views

Ray->triangle collision math seems to not work?

First time asking, pardon any mistakes I make :) I am programming a game from scratch, and the collision detection is giving me issues. I have AABB in place to check proximity, and if that reacts, ...
1
vote
1answer
68 views

Understanding constant acceleration in terms of game physics simulation

There are various integration methods that can be used for games. I am trying to write a simple physics engine deciding between semi-implicit Eular and Verlet variants. What I don't understand is ...
1
vote
1answer
28 views

Vector magnitude in orientation

First, a quick overview of my problem: I have a game entity which has a quaternion to represent its rotation/orientation. It also has a 3D vector in world space for its linear velocity. From the ...
2
votes
2answers
126 views

How to calculate a 3D orientation from 2D vanishing lines on an image?

Let say I have a image that represent a 3D scene. I did not have the 3D camera orientation of that scene (left, up and forward vectors) and i'd like to calculate it. On that picture, I draw the ...
0
votes
2answers
65 views

Rotating point around another point

I can't manage to rotate point around another point. I did some searching around google and found algorithm that should work and it kinda does but it also moves the point I am rotating closer to ...
5
votes
4answers
2k views

What is the simplest way to calculate distance in a 3D environment?

What is the simplest way to programmatically calculate difference between two points in a 3D game environment? I am trying to sort a list of light sources by how close they are to an entity, so that ...
0
votes
1answer
137 views

Vector-based Pong-ball bounce calculations

I'm making a 2D game with pads and balls, sort of like Pong, in Unity 4.6.1. The calculations, however, won't be (very) Unity-specific. The pads are going to appear in various rotations, and therefore ...
1
vote
1answer
64 views

“aim at” in 3D space algorithm

I'd to calculate the cartesian rotate values of "aiming" one point at another in 3D space. For example, assuming rotation order of XYZ: Point A is at [0, 0, 0] Point B is at [2, 2, 0] If point A was ...