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
1answer
55 views

How to draw splatter (one color) on 2D grid to cover approximate number of pixels? (looking for algorithm/math answers)

Imagine a 2D grid, where water stain increasing because of water drops. But not in plain circular way but more like noisy-splatter way. Or like corruption way. I want to create effect that will ...
1
vote
1answer
91 views

How to implement a simple Scrollbar

I'm making a simple UI system for a small game and i'm having some difficulty to implement a Scrollbar. At the moment i'm having two major problems that i need some help to solve: . Calculating the &...
1
vote
1answer
32 views

Space torque semi-independent of center of mass

I am making a 2d user build spaceship game that allows the user to place thrusters where they would like. I've read a bunch of posts in a lot of places including stack exchange on how determine the ...
1
vote
1answer
88 views

How can I create this springy oscillating motion chasing / orbiting the mouse?

I'm trying to recreate this motion, I think most of the motion is based on this formula \begin{eqnarray} x(t) &=& A e^{-\gamma t/2} \cos(\omega t - \phi) \\ y(t) &=& B e^{-\gamma t/2} ...
0
votes
0answers
46 views

How do I replicate this camera effect?

I am trying to re-construct the camera logic of RE4 that is applied when the player aims a gun. I have attached a hack to RE4 which enables the user to change the camera's FOV. Because of that I ...
0
votes
3answers
152 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 ...
0
votes
1answer
30 views

Calculating view matrix from rotation, elevation and location

I have the rotation(A), elevation(B) and location(C) of a camera in a left handed 3d space. +...
0
votes
1answer
101 views

Best way to implement a to hit formula based on provided stats

There are a ton of these questions, some can get really mathy - which is fine, but I am looking for a simple way based on a few stats, I thought I came up with one, so I will share it in hopes that ...
1
vote
1answer
48 views

How to best deal with percentage from gear and skills when stacking

I have a issue I am unsure the best way to go about solving. Developing a game I store all the "percentage boosts" a character could get either from skills, equipment, quest items or whatnot ...
1
vote
0answers
48 views

Why does the clip length of an animation not match my math?

I need to re-create an existing animation. The new animation should have the same amount of frames and length and FPS. Unity shows the following for the original / existing animation: As one can see, ...
1
vote
0answers
35 views

how can I normalize the speed of a polygon moving over a series of connected quadratic bezier curves with varying lengths?

I am generating a bunch of quadratic curves that are connected together, creating an array of curves, and a function which returns the position on the curve for a given time. ...
1
vote
0answers
22 views

How can I draw a partial circle with LineRenderer?

I'm using the following code, which I found online, to draw a circle with a predefined radius centred on a predefined point in LineRenderer (2D game). ...
0
votes
1answer
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 ...
2
votes
1answer
96 views

Matrix math in cascade shadow mapping

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 ...
2
votes
1answer
283 views

Drawing OpenGL camera frustum

I am trying to display camera frustum in my OpenGL application. I calculate the vertices of the frustum pyramid using reverse projection from screen space to world space. The camera uses perspective ...
-1
votes
1answer
116 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 ...
4
votes
2answers
109 views

Can't figure out math for converting negative indices of my voxels and chunks to positives

In my voxel game, I'm trying to spawn chunks in all directions. But since my world starts at 0,0,0, some chunks can spawn at negative positions like ...
1
vote
1answer
76 views

RNG random numbers/preset payout rate contradiction

Taking a casino slot machine for example: How can the probability of a payout TRULY be random with a preset payout rate? If a casino has slots programmed to a specific rate or percentage of payout, ...
0
votes
1answer
24 views

Euler Angles of Any Great Circle from hit.point of a sphere

How do you get the Euler Angles of Euler Angles of Any Great Circle that surrounds the raycast hit.point of a sphere?
0
votes
1answer
30 views

Ray-Triangle Intersection: does the direction of the triangle normal matter?

Found an article here about ray triangle intersection: https://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-rendering-a-triangle/ray-triangle-intersection-geometric-solution It states ...
0
votes
1answer
44 views

Movement within a circle, but the circle bends around obstacles?

I wish I knew a better way to phrase this, but I want to make an object move from point to point inside a circle. But I also want that "circle" to bend around obstacles, so that no matter ...
0
votes
1answer
45 views

How to construct a matrix with the following mapping

How would I create a matrix that maps coordinates like so: Near plane x: [-3,3] -> [-1,1] y: [-6,2] -> [-1,1] z: 2 -> -1 Far plane ...
0
votes
1answer
30 views

How to check if a point is on the plane given bottom-right point, top-left point, normal and the quaternion rotation of the plane

I know the world positions of A and B. We are also given the vector normal and the quaternion rotation of the plane How do I check if a point lies on the plane?
0
votes
1answer
68 views

How to rotate multi-tile structure on grid?

I need to be able to place structures in my game that span multiple tiles and can also be rotated. My idea on how to solve this would be to use 2D arrays that hold data about the structure. EXAMPLE: (...
0
votes
1answer
45 views

How to properly overflow 2D coordinates on an overflowing/circular map?

I made a simple Snake game designed for trying Snake bots. I thought the base map functions work, but now I found there is an error. What I need is to properly translate any coordinates outside the ...
0
votes
0answers
26 views

Get direction vector of camera in voxel game

I am currently working on a Minecraft clone (a voxel game). The feature I'm working on is the ability to break blocks. I have a ray-casting/ray tracing algorithm for traversing the voxels, but the ...
0
votes
1answer
34 views

How to project a vector onto a plane, but not along plane normal?

In 3d space, is there any way to project a vector onto a plane, but alongside the UP vector (0,1,0) instead of the plane normal? If so, then how do I do that and what is it called?
1
vote
2answers
50 views

Given its direction, and another vector that begins at the same point, how can I find the magnitude of that vector using only vector math?

I've solved this using the law of sines, but I was wondering if there's a way to do this with just vector math. Here's a diagram that will hopefully help illustrate what I'm trying to do: Given ...
0
votes
0answers
29 views

Helmet Mounted Display Math

I'm trying to create a helmet mounted display as a mod for a flight simulator. Unfortunately, I've been trying to figure out the math for this, but, to be honest, I'm stuck. I've done my best to look ...
1
vote
0answers
55 views

How can I calculate the inertia tensor of a hollow object defined by a triangle mesh?

I want to calculate the mass, center of mass, and inertia tensor of player created objects. Some of the objects will be hollow instead of solid. I am creating a closed triangle mesh for their object. ...
0
votes
0answers
24 views

Calculating the bouncing ball bounce height while on platforms

I tried to calculate the bounce height for the bouncing ball however it ends up shaking against the moving platform after it finishes bouncing. grav_val in this ...
0
votes
2answers
86 views

How do I set the size of a single 'unit' in my game?

I'm currently trying to remake/port an old game created on Unreal Engine 2.5 to my own engine, and I have access to its physics data. It's using a scale of 80 units per meter, or 1 unit = 1.25cm. The ...
0
votes
1answer
46 views

Predict future position of a moving body in Phaser arcade physics

I am looking for an equation for predicting the future position of a moving arcade physics body in Phaser 3. The body has drag applied and isDamping set to true. Phaser applies the drag using the ...
0
votes
0answers
63 views

How to project a Matcap correctly in Amplify Shader Editor

Unity's Amplify Shader Editor comes with an example of matcap nodes setup, however, the matcap projection in this example is incorrect. As you can see the texture becomes distorted when it's on de ...
0
votes
1answer
101 views

convert world to screen coordinates with camera position and camera angle

Heyho :) I'm trying to convert world coordinates to screen coordinates. I have available: fov, screen width, screen height, camera position, camera angle and obviously the position of the object in ...
1
vote
0answers
35 views

Reinterpreting point inside a distorted cube

Given a cube: And a point anywhere inside that cube. Could that point be reinterpreted given any kind of deformation applied to the cube? I.e., where would that point be inside the deformed cube? ...
0
votes
2answers
443 views

what is the math behind the parenting a transform in unity?

in unity when you parent an object or transform with another object, all transform(position, rotation, scale) are calculated depending on that parent object. sometimes we need to know about the local ...
0
votes
1answer
22 views

How do I resolve a collision in SAT-3D when the projection axis is zero?

I am doing SAT in 3D, right now just between cuboids/3D rects (idk the terminology). I have intersection working fully, and static collision works as long as the projection axis is not zero. But if it ...
0
votes
1answer
77 views

Is speed and direction generally combined into one vector, or separated into two?

Couldn't find this answered already, surprisingly. For example, for a game (in my case a 2D top-down one), there could be advantages to doing so. For example, whenever you want to change an entity's ...
0
votes
0answers
30 views

get the value of lerp at the mouse position?

I want to get the value t (value of lerp ()) between two lines and the position of the mouse and draw a gray line that goes from line a to line b. what is the value of lerp at the mouse position?
0
votes
1answer
15 views

How can I rotate the two endpoints of a line around the line's center in 3d?

The object is a capsule. I have the position of the object vector3, and the orientation of the object, a quaternion. I want to construct a line which goes through the middle of the capsule with the ...
0
votes
2answers
36 views

How to avoid entities flying far away when tabbing out and then tabbing back in?

I'm developing a game which uses a standard Entity-Component-System. Every frame, the PhysicsSystem runs, which, among other things, updates the position of ...
0
votes
1answer
15 views

Select box-shape grid between two positions on tilemap

I want to be able to click and hold on a certain point and mark it as startPosition. Then, while the mouse is held down and moved, mark that second position as <...
1
vote
3answers
143 views

2d diagonally velocity greater than straight-line velocity. How to fix?

If I have a topdown rpg type game. And movement in 8 directions (N/E/S/W/NE/NW/SE/SW) in a 2d game that involves both x and y velocity. I'm finding when i'm moving in the diagonal directions i'm ...
0
votes
1answer
30 views

Place tiles along a specific axis / direction

I want to be able to place tiles only in the direction I've started "drawing" them. For an example, if I click and hold on tile at position (0,0), and ...
0
votes
1answer
34 views

Map circular thumbstick to square

I want to make a plane controller using SDL2. I want to use one joystick for pitch/roll. Y-axis sets the pitch-flaps, and X-axis sets the roll-flaps. But there is one problem: Say I want to fully ...
0
votes
1answer
63 views

Normalize a rotation around the Z-axis (issue with GLM)

I'm trying to undo some transformations coming from an external tool*. I'm getting different results depending on subtle differences in the input and wondering how to convert to a rotation about the Z-...
1
vote
1answer
50 views

Skill button cooldown

When a spell is on cooldown I display a "unfilling" black bar over the spell GUI until the cooldown is reached. Problem is when i have more than one second of cooldown the scale of the "...
1
vote
0answers
50 views

Game Design. Question about balance progression [closed]

Playing in the main mode, the player receives Glory for victory, and for defeat, loses it. When the player reaches the required number of Glory, he moves to the next League. There are N Leagues in the ...
0
votes
1answer
28 views

track 2D offset after rotation

red is my origin point, blue is my offset, both are 2D vectors, how can calculate blue after rotation? this is the code I've been trying(just throwing things against a wall to see what sticks) ...

1
2
3 4 5
37