2022 Developer Survey is open! Take survey.

Questions tagged [mathematics]

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

Filter by
Sorted by
Tagged with
1 vote
2 answers
20 views

Libgdx World point to screen point

It seems like converting a screen point to a world point is easy in libgdx but going from the world point to a screen point is quite tricky. So How do I convert a world point into a screen point?
user avatar
0 votes
1 answer
39 views

Predicting Inclines and Declines for projectiles

For background, I am working on a top-down fighting game. I'm trying to create an archer class, in which the arrow sort of predicts the inclines/declines (moving it about the Y-axis [or up/down]). A ...
user avatar
  • 11
0 votes
2 answers
46 views

Finding the position of a point based on a relative point inside a quad

I'm trying to get the relative point position on a quad using a [0,1] Vector2, like in the picture below: The red dots are relative positions. What I'm trying to make is a function that takes the A,B,...
user avatar
0 votes
2 answers
73 views

How to find the mathematical relationship between 2 variables?

I am trying to find an equation that semi-accurately describes the 1 psi blast range of a nuclear explosion given the yield. I am using Nukemap on nuclearsecrecy.com to find 1 psi blast range at ...
user avatar
1 vote
1 answer
39 views

reposition object in circle

As you can see on the image, I have a p1 and p2 objects with (x,y) coordinates which I know the values, and I know radius of all these circle objects. However, I want to calculate new position x,y ...
user avatar
  • 115
0 votes
2 answers
60 views

X axis intersection with inverted Y axis coordinates

I'm making a visual clue for the player to know where (and more or less when) an asteroid is going to enter the screen. For this I'm using a triangle pointing at the incoming object and color ...
user avatar
  • 13
0 votes
1 answer
47 views

How to sort leaderboards, given wins and total games played?

The game is card game. The only results I get is wins and TGP (total games played). Losses = TGP - wins. I want to rank the players in the most fair way without making it too complex. What I have ...
user avatar
0 votes
1 answer
22 views

Matrix math: How to specify camera distance so that an object with a given size is completely visible?

This is my code that draws a top down view tile based map. But Iam do not know how high the camera needs to be placed in the sky so that the map is fully visible so that nothing is cut away and I do ...
user avatar
  • 334
0 votes
0 answers
13 views

How to convert gesture angle to 3D direction?

I have a angle that is created based on the direction of a gesture, how would I turn this angle into a 3D direction to move an object in 3D space along a straight path based on the angle. The closest ...
user avatar
0 votes
1 answer
36 views

How to round to a multiple of 0.25? [duplicate]

I have a problem when I any rational number so that it's 0.25, 0.5, 0.75, etc. ...
user avatar
  • 507
0 votes
2 answers
37 views

Is it possible to project a vector on another vector to calculate the distance without raycasting

I have the following game scenario: Player is P and there are 2 enemies E1 and E2 I want to calculate the distance between the ennemies and the player base which is anywhere in that green line, and ...
user avatar
0 votes
1 answer
40 views

Get index of chunk in flattened 2d array from world position

I have a world which is divided in chunks and saved in a flattened 2d array. The world is currently 80 units wide and high, and each chunk represent a 20x20 unit area. This gives that in my flattened ...
user avatar
1 vote
1 answer
119 views

How to slide along a wall at full speed?

I was reading this answer, and while it works for that use-case, mine is slightly different (simpler?), but I can't figure out how to do it. What I'm looking for is a way for the player to retain ...
user avatar
0 votes
1 answer
23 views

Find out (general) orientation of cube faces with rotated and translated camera

I have the following problem. I have a camera that is initially looking at a cube. The cube is with center at (0, 0, 0). The camera that is initially on (0, 0, 60). The camera can rotate and translate ...
user avatar
0 votes
0 answers
20 views

Projectile Aim Prediction with Target Acceleration and Bullet Deceleration Varying with Angle

I previously asked a question about this topic here, and now I'd want to review if the offered solutions worked, and then frame a new inquiry based on the difficulties and issues that resulted. So my ...
user avatar
0 votes
1 answer
88 views

Intercept an accelerating object with a constant velocity projectile

I want to calculate the time that it takes to intercept a moving target "plane" with a projectile. For example I have two 3 dimensional vectors (2 locations in 3D space). ...
user avatar
-1 votes
2 answers
47 views

How to interpolate angular data properly

I have been trying to interpolate raw angular data in degree (for a flow map grid) but any attempt fails because there is always two path, and I can't figure out how to interpolate on the shorter one ...
user avatar
  • 197
0 votes
1 answer
29 views

How are transformation matrices usually represented?

I know the bare minimum to do matrix multiplication and have implemented them from scratch a few times for various purposes, but every time I do, I make sure to be very clear to myself about where are ...
user avatar
0 votes
1 answer
85 views

How to make object follow the mouse OpenGL?

I am trying to move an object on the 2D plane to follow the mouse position. I converted the mouse's XY and depth buffer value to world space coordinates, but the problem is that when I run the program,...
user avatar
0 votes
1 answer
65 views

Is Quaternion math really practical knowledge for a graphics programmer?

I've recently had a graphics programmer interview and I was asked about math that is under the hood of quaternions. I briefly mentioned the formulas of using quaternions as rotations, but the ...
user avatar
2 votes
0 answers
16 views

Create a quad that faces a given normal [duplicate]

Let's imagine that we have a given normal, (it could be done with source and destination points but let's say that source is 0 0 0 and the destination has been already normalized) What could be the ...
user avatar
1 vote
1 answer
38 views

Rotating an Icon On MiniMap

I'm creating a minimap for my game. There is a mission where the player has to escort an NPC to an area. The minimap shows the player, the NPC and the location. The NPC icon sends an arrow from it's ...
user avatar
  • 31
0 votes
0 answers
21 views

writing a custom Quaternion.FromTo

I'm using the new Unity.Mathematics library. I'm trying to to replace Quaternion.FromTo(Vector3 from, Vector3 to) which returns a quaternion with what it would take ...
user avatar
  • 723
1 vote
1 answer
58 views

DooM P_BulletSlope function , how does it works

I'm trying to understand how DOOM source code works, the problem is I don't understand a few things, why is it 16 * 64 * FRACUNIT ? , i don't get it. ...
user avatar
  • 111
0 votes
1 answer
13 views

Math function equivalence for deferred transparency blending

if one consider the following blending operation: color1*src_alpha blended with color2*(1-src_alpha) Where ...
user avatar
  • 27
0 votes
0 answers
24 views

Proportional Navigation Missile Guidance with Blueprints

I'm trying to make a more realistic/responsive guided missile for a mod I'm making in a UE4 game. I've had some limited success with some simpler algorithms like Required Acceleration = LOS * LOS_Rate ...
user avatar
0 votes
1 answer
72 views

How to find the maximum distance a target point can be hit from a launched projectile

I'm determining a trajectory necessary to hit target B with a projectile launched from point A with a given velocity. No problems there. Obviously, not all points B can be hit with a fixed velocity, ...
user avatar
  • 591
0 votes
1 answer
18 views

circles originating from player position not showing up on pygame window

I'm kinda new to python and pygame, anyone know why this won't show bullets coming out from my character? ...
user avatar
0 votes
1 answer
64 views

Find vertical angle between two objects

I'm working on a project that involves a battleship with multiple turrets on it. The turrets have limited movement on both horizontal and vertical axis. When checking if they can target the player I ...
user avatar
  • 31
0 votes
0 answers
28 views

Finding tiles crossed given a circular path

I have a path that consists of a circular path, the map is broken up into equally sized cubic tiles, I would like to find which tiles were crossed given an arbitrary circular path. ie Given a start ...
user avatar
1 vote
0 answers
33 views

how to efficiently raytrace a rectangle side in 8bits without mul and div?

Imagine you are on a hardware that is 8bits like the nes or the game boy, NO mul no div, only add and shift. Given a rectangle or integer size nk*mk, where k is the size of the underlying grid, and P ...
user avatar
  • 197
1 vote
2 answers
46 views

How to solve for the angle of a axis/angle rotation that gets me closest to a specific orientation

I’m using a 3D affine transform (a 4x4 matrix of floats) to represent a combination of translations and rotations in 3D space doing a sort of 3D turtle graphics kind of thing. From this state I know ...
user avatar
  • 138
1 vote
0 answers
27 views

Calculate 2d rotation to target (uniformly accelerated rotation, constant speed)

I'm trying to calculate an uniformly accelerated rotation for the autopilot module in my 3d space game shooter. The autopilot should fly the spaceship to any given point in the 3d space on the ...
user avatar
2 votes
2 answers
67 views

How to implement cylindrical projection?

This question (and particularly, its answer) talked about how traditional, planar projection matches most monitors... except when it doesn't. Assuming I'm a glutton for punishment, and really, really ...
user avatar
  • 141
0 votes
1 answer
49 views

How to calculate accelation times and vector to orient a pointmass to a new orientation

I'm trying to design a space game where the user has 2 types of input: forward and backwards thrust in the current direction change orientation The game is based on actual physics, for the sake of ...
user avatar
0 votes
0 answers
26 views

Program doesn't detect a ray triangle intersection correctly

Every frame I check if a ray intersects a triangle. But in practice program tell me that triangle is intersected only when I move camera on to it's position. I don't even have to put cursor on a ...
user avatar
0 votes
0 answers
12 views

How to convert local location to global location given orientation?

I'm working with Unreal Engine and I've come across a scenario where I have a location vector point in local coordinates and I need to transform it to global ...
user avatar
0 votes
0 answers
26 views

Why do we still see infinity vector space after normalizing World space? ( Unity Shader Graph)

Why do we still see infinity space after normalizing vector space? I assumed that some kind of effect would be obtained. As I see what happens to the space after it is normalized and how this ...
user avatar
0 votes
0 answers
7 views

Why do we see such effect after Normalize X value from Position Node ( in World Space )? ( Unity Shader Graph ) [duplicate]

Why do we see such effect after normalize X coordiante from Position Node ( in World Space )? How does it works? What Normalize node do with X Coordinate? Do we normalize X value of vector or length ...
user avatar
0 votes
1 answer
218 views

How to calculate item drop rate?

I am developing an RPG that will be played in the browser, so far the development is going very well. However, I reached a point in the project where I'm "stuck" because I can't find a good ...
user avatar
  • 197
1 vote
0 answers
61 views

Maths behind Unity rigidbody.AddForce

I've tried to understand the Maths behind AddForce, as to reproduce it using rigidbody.velocity +=. Based on the formulas ...
user avatar
0 votes
1 answer
27 views

Given a set of points with color values, finding a gradated color value from a given position

I guess the verb form of gradient is "gradate" and not "gradiate"? Hi! I have a set of 2D points (actually 3D, but we can ignore the Y axis unless it's trivial) bound to color ...
user avatar
1 vote
1 answer
72 views

Dividing amount of exp between rank A and B into a curve?

In my game I have a rank system. You start at rank A, and then you can level from level 1 to level 10. When you reach level 10, you get promoted to rank B, and you go from level 1 to 10 again, and ...
user avatar
  • 113
1 vote
1 answer
143 views

Unity3d - Tile-based "Slippy" map rendered on a sphere (earth)

Scenario I'm creating a spherical version of a slippy map using osm tiles and my luck has been limited thus far. I'm starting to think my strategy has lead me astray and that I need to start from ...
user avatar
  • 191
1 vote
1 answer
42 views

Snap joystick value to minimum magnitude when it falls below

I got a joystick displayed in the image below with range -1 to 1. Green area is 80% of the total circle and yellow area is 20%. I want to get corrected values for both areas. For example: If given ...
user avatar
  • 113
0 votes
1 answer
133 views

How do I calculate a matrix to render a mirror about a plane using GLM?

I've been trying to work out how to render a mirror for a while now, but a lot of resources I find either use very outdated tools I'm not familiar with, appear to be college slides referencing other ...
user avatar
0 votes
1 answer
133 views

Math formula for: the higher the stress, the higher the difficulty

My game has a stat called Stress, and the player has some missions to do. Each mission has a computed stat called Difficulty ...
user avatar
0 votes
1 answer
36 views

Compass objective indicator points towards wrong direction

I have a compass that is pointing towards player forward direction. ...
user avatar
0 votes
2 answers
168 views

Quaternions distorting object in Metal

I've been trying to get rotations with quaternions to work for a while now, and I feel I am very close to it actually working but I just can't get it to work. I do not have a view matrix yet and am ...
user avatar
1 vote
1 answer
58 views

Find the smallest angle to turn between two angles in range 0..1

I have a function for approaching a value to a target by a certain amount: ...
user avatar
  • 217

1
2 3 4 5
38