# Questions tagged [mathematics]

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

1,839 questions
Filter by
Sorted by
Tagged with
185 views

### How does lookAt matrix math work?

Can someone provide me an explanation of how the lookAt matrix works? ...
426 views

### intersection of primitive in a unit wrapping 3D space

is there people good enough for a math problem (for a shader)? I want to write an algorithm that would intersect primitives (triangles, squares, circle, sphere, cube, cylinder) inside a unit wrapping ...
843 views

### Why aren't regular quadratic and cubic splines used much in games?

After investigating a bit about splines and reading a bunch of docs, I have noticed regular quadratic and cubic splines are not used very much in games. Splines using quadratic/cubic Bézier curves, ...
45 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 ...
122 views

1k views

### Converting Euler rotation angles from Z up to Y up (Max to OpenGL)

I'm working on pulling geometry and it's transformation from a 3DS Max exported FBX (Z-up) to an OpenGL model format (Y-up). The main problem is I intend to keep the transformations as Translation and ...
29 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 ...
36 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 ...
81 views

I am implementing cascade shadow mapping algorithm and currently stuck with matrix transformations - my AABBs, when projected in light space are pointing in the direction opposite to the light: I was ...
31 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 ...
74 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 ...
14k views

### How do I find the circumcenter of a triangle in 3D?

I want to find the circumcenter of a triangle. Wolfram only shows how to find the circumcircle of a triangle in R2. How can I find the circumcenter of a triangle in R3?
66 views

### Speed after an angled collision?

I can calculate the speed when there is no angle, but I can't calculate the speed when it is angle. Physics paramaters: ...
344 views

### Rotating sprite 180 deg

I should say first, that I have the rotation down. Its just that I want my square to rotate exactly 180 degrees. Currently, it will rotate but it will rotate but by less each jump. So after several ...
75 views

### Calculating child world translation, rotation and scale

I'd like to know if it's possible to calculate a child's world translation, rotation and scale individually. I'm used to seeing devs resorting to matrix multiplication and then decomposition, like so: ...
96 views

### What happens if first we scale a rotation matrix and then multiply it with an object?

This question has been bothering me lately. I know the correct order to scale, rotate and transform a matrix but the question I have is very different. What if we first scale our rotation matrix by ...
594 views

### How can I find the offset rotation and position between two objects in 3D?

I have two objects in 3 dimensions, one of them (Child) is attached to the other one (Parent) using the offset between them (XYZ ...
2k views

### Terracing mountain features

I'm looking to replicate a procedural terrain effect I found on a portfolio/blog site a few days ago. Quoting the site, the terracing was generated through, "multiplying [the final height] by some ...
68 views

### FBM alteration based on derivative and noise value

I'm still working on my procedural terrain generation and kind of sniffing ideas from Sean Murray (No Man's Sky programmer). So I watched this GDC17 presentation, but some things just don't make sense ...
77 views

### How to design a system that allows for custom equations of movement?

I'm developing a top-down shooter and I currently have a PhysicsSystem which operates on TransformComponents. Basically, it ...
360 views

### (Unity3D) Determine If Ray Intersects Given Rectangle

I'm building a city generator for my game and I want to ensure buildings are never placed in such a way that they overlap roads. Currently I have the system build the roads, then place buildings ...
43 views

### How do I predict where a player will be next in Forge/MCP?

I am trying to predict where a player will be next based on where they are now in Java. I have their XYZ position, their XYZ motion, but I don't have their speed. How can I predict where they will be ...
25 views

### Compass objective indicator points towards wrong direction

I have a compass that is pointing towards player forward direction. ...
115 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 ...
43 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: ...
28 views

### How to find Particle Position at Time with velocity and friction?

I have a Particle p. A particle consists of a start position p0,an age t, a velocity ...
112 views

### Finding rotation quaternion from orthonormal basis?

Given three 3D unit vectors $a$, $b$, $c$ such that: $a \times b = c$ $b \times c = a$ $c \times a = b$ (ie $a, b, c$ form an orthonormal basis) How do we calculate a unit ...
78 views

### What kind of math is used by this camera panning script?

I'm not fluent in English so I apologize in advance. I have found a source code in order to pan camera by touch - here it is: ...
56 views

### Isometric projection, calculate camera angle for specific tile height

I'm experimenting with different tile dimensions while rendering 3D assets for an isometric game (or dimetric to be exact). Everyone does a 2:1 ratio so the tiles in isometric view are 256wx128h, ...
119 views

### How to clip cut-off using different frustrum than that of original camera? How to cut plane by pyramid shape?

SOURCE : http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Mitchell_LightShafts.pdf This process is part of creating light draft effect. And I am suggested to do the described process in ...
22 views

### Dynamic circular motion increases in energy

I am experimenting with designs for physics engines for which I use particles and fields like magnet fields. In magnet fields you have a thing called Lorentz force ...
109 views

### How are Spot It cards generated?

Spot It is a card game 55 cards. Each card has exactly 8 symbols on it (though the total number of different symbols used in the 55 card set is 57). For any two cards in the deck, they share exactly ...
84 views

### Cylindrical billboarding around an arbitrary axis in geometry shader

I found an answer on this site relating to this question already, but it doesn't seem applicable in the context of my project. Basically I'd like to create a method which fits this signature: ...
68 views

### Find those points lying on a circle from a ton of points

Given a 2d scene and 10,000 players with coordinates in the scene, I want to implement a function, the input is a circle with the center coords and its radius, the output is those players that lie on ...
184 views

### Godot - Offscreen Target Indicator

I have a crosshair image that will lock onto enemies that are visible in the camera and will stay on the edge of the screen when the enemy is offscreen. This works until you face more than 90º away ...
70 views

### What would be the effect of making Wealth a diminishing-returns variable?

I've been playing a bunch of Fallen London lately, and I find it interesting how they do "pyramid qualities": Achieving level X in something requires +X points.. 1 for level 1, 2 more for ...
63 views

### Knockback to zone on non-rectangular field

I have a playing field which is divided in 4 zones (as seen on the image below) The player (blue) is on the second zone while there are 2 enemies (red) on the third zone. When the player throws an ...
64 views

### How to gradually interpolate smoothly between two yaw rotations in Minecraft MCP/Forge?

I am coding a custom client for Minecraft using MCP. (Please no hate, I'm not making a hacked client!) I have two variables currentYaw which is the current yaw ...
51 views

### How to compute an incremental movement: $f(t+h)-f(t)$ or $f(t)-f(t-h)$?

For the sake of getting precise position, I think I need you to clarify whether or not the tutorial calculation is incorrect and my calculation is correct. Assume we want to move an Actor up and down ...
77 views

### Could you explain how this GameObject rotating around another GameObject works?

I'm just learning Unity and I follow a tutorial for a simple game which I want to build up from. I'm already mostly done with the course and at the end a "boss enemy" gets implemented. Its ...
114 views

### Formula for stacking percentages to keep them from getting out of control

I have a game that has a mechanic, where a specific class can stack what are called "life stealing enchantments" to steal greater amounts of health from the enemy depending on the type of ...
153 views

### Getting Model View Matrix by hand

Right now I'm trying to calculate the model view matrix by hand... The App is 2D. I have something like this: ...
154 views

### How to predict where the soccer ball should be intercepted by an AI player after being kicked?

This question has been asked many times before, but most of the answers give solution to the problem where ball (target) is assumed to be moving at a constant velocity. In my scenario, I'm making a ...
389 views

### Capsule to Sphere Collision

For my Maths unit at university, we have to manually calculate if a sphere is colliding with a capsule collider. The information I have to go with is this; You have the following Sphere: LadyBird3 -...
134 views

### Why is the derivative important in game development? How did you use it in a real scenario?

I'm really eager to know how a programmer finds useful a derivative in game development, using a real scenario as an example. Also I plan to use this question to understand the importance of ...
105 views

### Java Simple 2D Grid Pathfinding

I want to code some basic pathfinding for my bot in Java. Below is a 2D grid representation of the 3D world. 0s being the places you can go, and 1s being the places that you cannot go. ...
36k views

### How can I project a 3D point onto a 3D line?

Let's say I have a line defined by two points, A and B, both in the form (x, y, z). These ...
31 views

### How to find player movement speed in Forge/MCP?

I want to predict where a player will be next based on where they are now. I have access to their XYZ, their motion in each direction, but I don't know how fast they are moving. Let's say that the ...