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
0answers
12 views

Screen coordinates to letterboxed view

So I have letter boxing working properly (it's not really important but I'll post that bit of code too), but I'm trying to figure out the point/vector arithmetic for translating (projecting) screen ...
0
votes
1answer
23 views

How to make a joystick follow the touch around a starting point using atan2?

I would like to move a joystick, and be able to go beyond the limit of the circle, and the joystick should follow the angle from the touch (the touch is moving), but it should stay on the circle. It ...
0
votes
1answer
33 views

Given a constant rotation and target point, find position so that point will be in camera center

Given a fixed rotation and a target "center" point, how to I find the position the camera should be in so that that point is the center? LookAt changes the rotation keeping the position constant. ...
0
votes
3answers
56 views

Non equi-probable random function

I was trying to find or make a function which is not equi-probable, meaning some values are less probable than others. Apparently what I want has something to deal with ...
1
vote
0answers
59 views

Transformed Vertices have wrong Z Axis

For quite some time I've been working on my open 3D game engine, to learn how this stuff works. You can see the full codebase relating to my problem here on GitHub. I'm using an OpenGL 3.3 Core ...
0
votes
0answers
35 views

Libgdx trying to get reflection of ball with plane in 3D space

I just cannot seem to get the right reflection result. Have tried reordering the operations but none seem to work. Hoping someone might tell me what I am doing wrong. Trying to accomplish the formula ...
-1
votes
1answer
76 views

Cannot find bug in frustum culling code

I've written some code for frustum culling, but for some reason, it is not working, and i can't find the bug in it... Maybe a bug in the math, somewhere? So, i'm asking you if anyone could check these ...
0
votes
2answers
73 views

Circle-Circle collision resolution

This seems easy but I can't figure it out, when I have one circle(c1) collide with another(c2) I give the c2 circle the heading of c1 and send the c1 circle on the normal vector to the heading (the ...
0
votes
1answer
52 views

Quaternion Slerp and Lerp implementation (with overshoot)

I am working with Unity (C#) and was looking for an implementation of Slerp and possibly Lerp that allow overshoot (progress not strictly limited to 0..1 range). I want to do some tweening animation ...
-3
votes
2answers
103 views

How to find damage per second using Average Damage, Accuracy and Fire Rate Per Second? [closed]

I was wondering if anyone could help me establish a DPS equation using the variables 'Average Damage', 'Accuracy (%)', and 'Fire Rate Per Second'. Here is my table: Note: These numbers are ...
1
vote
2answers
52 views

How do I wrap an image around a sphere?

Ideally I'd like a reference of the math involved, so I can start breaking down the problem. The simplest thing I can deduce about this problem is that the part of the sphere that the user is ...
1
vote
1answer
56 views

Determine which face of a cube is facing the camera

I have a Cube with a unique color for each face. I made a script where I can swipe and rotate the Cube in increments of 90 degrees in each direction. what's the best way to determine which face of a ...
0
votes
0answers
18 views

C# Pathfinding in 2d array (procedural generation) [duplicate]

I have the following random example data in a 2d array 030 300 030 003 The 3 represents a room, the 0 represents its an empty block and 1 represents a corridor. Now i want for example the following ...
0
votes
3answers
82 views

2D Box Collision Trouble

Hello I am trying to handle some simple box collision (axis-aligned) in my top-down 2d game, but running into a problem. My game is running at a fixed time step, and checks for player-wall collision ...
0
votes
1answer
119 views

Rotate Object Towards Direction in 2D

For my RTS game's physics engine, I'm trying to find out a clever way to make a unit face the direction it's moving in. Given a Vector2d direction of movement (its normalized velocity), how can I ...
0
votes
2answers
76 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
100 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 ...
1
vote
3answers
103 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
172 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
88 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
16 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 ...
2
votes
0answers
59 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
44 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
102 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
53 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
87 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
74 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
200 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
67 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
56 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
235 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 ...
0
votes
1answer
66 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
52 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
47 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
34 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
118 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
61 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
43 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
265 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
888 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
52 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
63 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
63 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
1answer
113 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
15 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
116 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
59 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
46 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
79 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 ...