# Questions tagged [mathematics]

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

1,892 questions
Filter by
Sorted by
Tagged with
10 views

### Methods for generating unevenly distributed item stats?

Conceptually, generating item stats is the same as placing balls into buckets. An even distribution of 50 balls into 5 buckets looks like this: [10,10,10,10,10] whereas an uneven distribution might ...
• 633
17 views

### r/l/b/t parameters in orthographic projection?

I am trying to implement following: What are the l r b t units? I understood that r-l= is just ...
• 121
16 views

### How to change quaternion when flipping X axis?

For a given animation with the set of 3D coordinates of every joint and corresponding global rotations quaternions Q(X, Y, Z, W) in right-hand coordinates (Y-up, X-...
51 views

### Efficient calculation of billboard sprite transformations

I'm currently adding a billboard mode to animated sprites and static sprites in my 3D engine. The code below works fine, but I want to know if a more optimized solution exists. I've heard about ...
45 views

### Is putting the parentheses between the screen width divided by 2 to set on the screen for readability or clarification?

I'm using SFML & the book I'm reading has the following snippet of code: ...
• 41
58 views

### How is dyson sphere program building grid being calculated?

Here is a question I really want to know the answer. How is that : Done in unity ? I mean, after a bit of extensive research : ( example of what I found ) https://www.researchgate.net/figure/...
• 105
1 vote
68 views

### What branch of math do I need to learn to understand and use math for procedural animation? [closed]

I watched a video about procedural animation from t3ssel8r channel - YouTube video link. I was interested in this topic - programming curves and various dependencies, but I'm not strong in mathematics....
• 357
45 views

### Octagonal and dodecagonal tiling: is it possible?

this question rose out of interest of turn-based games, in which there mostly two type of tiling used: square-based and hexagon-based, and both have disadvantages. if you use squares, like in civ3, ...
106 views

### Does game design (numerical value planning such as attack/defense/ rates of critical hit) need a strong mathematical background?

I will go to college very soon and I want to choose math major. I want to know if being graduate with a strong mathematical background will help me success in game design. For example if I want to be ...
28 views

### Adding Z rotation to XY rotation without polluting the result

For context, I'm trying to make a 3rd person space game. The spaceship orientation is determined by the camera orientation. I also want to be able to control the roll of the ship(in my case, that is ...
18 views

### Calculate area with mouse clicked position unity

I have a feature which allows marking point on a surface and usnig raycast and mouse click position. You can click as many points as you want, then the last point connects with the first point to ...
• 1,868
101 views

### javascript top down circle to circle smooth collision detection

I've been looking through a lot of answers here: Resolving Circle-Circle collision Circle to Circle collision, checking each circle against all others Nestling into contact with a group of physics ...
72 views

### Player rotation using relative mouse movement instead of absolute

I'm working on a twin stick shooter where the player looks at the mouse cursor. Like most I use the absolute mouse position and the player's position to determine the direction and derive an angle. ...
• 1
31 views

### Tangent Space View Direction based factor value remap

I'm trying to setup a mask similar to what Fresnel produces. Unfortunately Fresnel gives pretty bad results at grazing angles so I ended up using this : ...
• 1,045
26 views

### Anchored Pull Function Breaks at Low Framerate

To start, I'm not working with an engine and am looking for some help fixing the math behind the function I created. Say we have anchor, ...
98 views

### Smooth lerp towards a moving target

I stumbled upon this function that lerp towards a moving target with exponential correction which works really well. The original author mentioned integrating the target position. Can anyone explain ...
• 11
62 views

### How do I respond to AABB collisions?

I'm coding a physics engine in Javascript. Forces, Gravity, Friction, AABBs are taken care of. Now, the big question: how do I respond to AABB collisions? Right now, when an object collides, it prints ...
35 views

### A point on a sphere surface needs to be converted to origin coordinate

I have a central point, a planet is moving around it on the orbit A (a circle) And the planet is rotating at a certain speed on its axis ( B ) I have a Data Structure representing the Base Mesh ...
• 105
1 vote
31 views

### Rotate an object relative to the player to face another object

Essentially, in my game, I have 3 objects: a player, a shield and a puck. I want to have the shield orbit the player to automatically face the puck. (So the position will change with the rotation). <...
1 vote
94 views

### Attack/Defence formula: ensure defender wins a certain percentage of the time

I have two simple stats for my attack formula, attack and defence. I was reading through this answer which made it seem like ...
• 111
1 vote
34 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?
• 159
46 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 ...
• 11
56 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,...
90 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 ...
1 vote
50 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 ...
• 115
73 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 ...
• 13
73 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 ...
26 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 ...
• 334
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 ...
64 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. ...
• 507
54 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 ...
• 470
53 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 ...
1 vote
161 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 ...
• 205
28 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 ...
39 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 ...
115 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). ...
55 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 ...
• 197
30 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 ...
181 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,...
86 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 ...
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 ...
1 vote
42 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 ...
• 31
27 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 ...
• 733
1 vote
67 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. ...
• 111
16 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 ...
• 47
39 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 ...
77 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, ...
• 591
23 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? ...