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
14 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
23 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
30 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
15 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
59 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
20 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
8 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 ...
1
vote
0answers
27 views

What is closing and separating velocity in Ian Millington's game physics book?

I'm working on a physics engine in C++ and chose Ian Millington's Physics Engine Development book as a guide and reference to help me out understand physics concepts and how to implement them. ...
0
votes
1answer
24 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
29 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
52 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
16 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
50 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
18 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
14 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
32 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
11 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
79 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
26 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
28 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
24 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
38 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
28 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
14 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) ...
0
votes
2answers
43 views

Rotating quaternion smoothly with acceleration and deceleration

I have this code for my linear acceleration and deceleration. ...
0
votes
1answer
44 views

How to do topdown collisions properly?

I'm trying to achieve grid/tile based collisions like "a link to the past"; here is an article showing it off (sliding off the corners and such). I'm currently using this type of collision ...
0
votes
1answer
27 views

Move vector A to vector B but stop X distance before reaching vector B and always be in front

I believe this is basic vector math, but I'm struggling with it. I have 2 objects (3D space, x, y, z), A (weapon) and B (camera). I want to move A to B's location, but then offset A from B so that it ...
0
votes
1answer
41 views

Problem with InverseTransformDirection and non-uniform scale

I made the plane to work with mesh vertices ...
0
votes
1answer
62 views

finding the angle of rotation of a 3d line

I have a line segment joining two 3D points AB, and a vector V which is normal to it. I need to know the angle of AB in the plane described with V as the plane normal, that is: in the plane of the two ...
1
vote
1answer
29 views

How to get all tiles along a straight vector path?

Let's say I have a 100x100 map of tiles where each tile is 16x16 pixels. How would I get all tiles along a path? For example, let's say I wanted to get a list of all tiles along the shortest direct ...
2
votes
1answer
74 views

Determining the price of a trade good depending on supply and demand of a marketplace

I've been meaning to add a market/trading system in my space-themed game where a player can buy from one station and sell it to another for profit, etc. (Examples would be Starsector, Elite: Dangerous,...
3
votes
2answers
81 views

Transactions on lists of coins of different values

For learning purposes, I am developing the first steps of an idle game with exponentially higher income numbers. Usual int, long, etc. can't store big enough numbers for that. I looked through many ...
0
votes
1answer
32 views

Angle between start and current rotation

I'm facing problem of the operations on rotations. I have a wheel with a start rotation of (0, 0, 0). The player has to rotate wheel 270 degrees in Y axis either left or right. During the rotation ...
0
votes
1answer
25 views

Offscreen waypoint indicator using X and Y screen position

I was wondering how I could achieve an offscreen indicator effect that helps direct the player to the next waypoint. My game is 3D, most solutions I have found are for 2D games (i.e Asteroids). See ...
0
votes
0answers
72 views

How to implement PCSS properly?

I'm trying to implement PCSS in OpenGL/GLSL, but I have problems understanding the details especially the conversions between the coordinate spaces. The existing implementations are so different from ...
0
votes
0answers
32 views

What is the math to project a 3D object's center onto a 2D plane?

What I really need is the x,y of the object when it is outside of the screen: I'm actually coding a UI in Objective-C, not a game. In this different kind of UI you navigate a 3D space with objects. ...
0
votes
1answer
30 views

How to interpolate colors around the spectrum of hues?

I wanted to generate a 7 segment display whose color brightness varies with time, this can be done by just using linear relationship. ...
1
vote
1answer
77 views

How does glm::lookAt produce a View Matrix?

Say we do this: glm::mat4 View = glm::lookAt(glm::vec3(4,3,-3), glm::vec3(0,0,0),glm::vec3(0,1,0)); And after printing to the console with glm tostring (column ...
0
votes
0answers
21 views

Efficient way to compare vectorial direction?

I have a bunch of random vectors representing a direction and four other vectors that we can distinguish with their pyramidal arrows at their extremity, they represent a boundary what i'd like to do ...
0
votes
1answer
50 views

Why my calculated value is far different from actual value?

I using CharacterController and not using a Rigidbody so I writing a script for downward velocity which is velocity=-9.81*(time) ...
1
vote
1answer
39 views

Is an inertia tensor in local-space always diagonal?

I'm looking at the implementation of a physics engine and I observe that the inertia tensor of a rigid body, in local-space coordinates, is stored as a 3 dimensional vector, rather than a 3x3 matrix, ...
0
votes
0answers
30 views

Slope detection in 2D platformers

I am currently shifting from unity to monogame to make 2d platformers. I am not aware of any sort of "raycasting" provided with monogame, I am aware of AABB collision detection and I am ...
2
votes
2answers
73 views

How to smoothly interpolate 2D camera with pan and zoom

I'm developing an animation application with 2D virtual camera. The camera viewport can be positioned and scaled in the keyframes and is then interpolated to render the final animation from the ...
8
votes
2answers
2k views

How to create a spiral brightness gradient

I am stuck on creating a brightness gradient that looks as below(the values are continuous from the inner circle). What formulae can create such brightness gradient? So that when _Time is added to it, ...
0
votes
2answers
85 views

Is there a simpler way to simplify the if statement? [closed]

The code below generate angle and radius based brightness gradient. As you can see I need to use 3 if statement to define 3 circle, wonder is there a single code that can create nth circle ...
0
votes
1answer
100 views

Help understanding radar sweep effect in shader code

Several days ago I asked about this question: How to construct a propeller clock in Unity? But I don't understand how the answer works. I have 0 knowledge about shaders, so I picked up a tutorial to ...
0
votes
1answer
45 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: ...
0
votes
0answers
78 views

Create Mesh in gap between tiles (in Unity3D)

I am loading two kinds of tiles (meshes in tile format) in Unity, both are placed in the environment correctly but there is a gap between these two tiles (see the picture below). I want to fill this ...
0
votes
0answers
33 views

How to fill with empty space with retangles

I have a 'square' class with the representation of its limits from the variables x1, y1 and x2, y1 these variables define points 1 and 3 of the same, in this case the coordinates would be (0,0), (10, -...
0
votes
1answer
40 views

How to create a Decisecond(0.1second) function that can use in the code?

I create a circular object and pivot the minute and second pointer on the middle of the object as below. Below is the code I use. ...

1
2 3 4 5
36