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
0
votes
0answers
36 views

Frustum culling issue at oblique angles

I am using the following algorithm to test if my camera frustum contains an axis-aligned bounding box: ...
0
votes
0answers
14 views

Triangle area selection using BVH raycasting

Let's assume I'm already storing a BVH acceleration structure per mesh on my engine and I'd like start making area selection like on many DCC tools out there, for instance, blender. With blender you ...
0
votes
0answers
15 views

Rotate relative to set point in a specified direction in a 3D space

I know there's a geometry formula to calculate the next point in rotation relative to another point in 2D but I'm working in 3D and I want to calculate the next position in specified direction as well....
1
vote
1answer
47 views

How to decompose a 4x4 TRS transformation matrix with negative scale?

As the title says I need to decompose 4x4 TRS transformation matrices and extract the proper scale vectors and the proper rotation vectors (or rotation quaternions). I know how to extract those ...
0
votes
0answers
31 views

Rotate object relative to camera position

I am trying to write code that is able to rotate object, based on camera position. So far I ended up with a code posted below. Moving mouse up and down (y input) caused to rotate object in y axis, ...
0
votes
1answer
36 views

How to tell which face of a cube is most visible to the camera?

Imagine a camera that shows a randomly rotated cube at an arbitrary position: The cube's pivot is in the center of the cube. This way its six faces could be referred as positive/negative X, Y or Z. ...
1
vote
2answers
44 views

How do I calculate/weight a diminishing damage formula based on N targets?

I'm making a game and had a look at the questions about calculating damage/diminishing returns here and here but I haven't quite been able to come up with a logarithmic function that satisfies this ...
1
vote
1answer
49 views

Calculating probabilities for a custom drop table system

I have a "drop table" / "loot table" / "item table" / "whatever you want to call it" system and I need to solve two Problems. Apologies in advance for the text ...
0
votes
1answer
51 views

How to Generate Level Map Based on Golden Ratio

I am trying to generate a map based on the Golden Ratio: a+b is to a as a is to b. I was looking at a JavaScript math library that had a built-in phi, but I wasn'...
1
vote
1answer
26 views

Can I get world-space z-near-plane vertices from projection matrix + z-near distance?

I'm trying to port ShaderToy VR shaders to WebXR (the new browser API for AR/VR devices). ShaderToy VR shaders expect two extra parameters: ray origin (view translation) and ray direction (unit vector ...
0
votes
0answers
50 views

Aircraft trajectory prediction

I have an aircraft that is controlled by player and i need to predict it's position at needed time. It's not a problem if the plane is just moving straight but most of the time aircraft is maneuring. ...
0
votes
2answers
124 views

When are oblique triangles used in game development?

I'm working on a project that explains how trigonometry is used in video games, and I need to mention oblique triangles. However, as far as I know, only right triangle diagrams are used in video games ...
6
votes
3answers
2k views

Rotation grid positions

I'm dealing with objects on 15x15 chunks in my game. I'd like the chunks to rotate, for example, rotation version 0 is the original position of 2,5; (EDIT: Oops, rotation 2 and 3 names need switching ...
1
vote
1answer
35 views

Rotation matrix to look at point p

Assume a left-handed coordinate system where x is right, y is up, and z is into the screen. You have a unit vector pointing up along the y-axis. What's the rotation matrix for pointing the unit vector ...
1
vote
0answers
24 views

Formula to convert zoomed in game space co-ords to UI

I need to come up with a formula to convert variable zoomed-in game space co-ords to UI co-ords. The engine I'm using is not traditional so there's no inbuilt function (convertToUISpace etc). Now I ...
1
vote
2answers
106 views

Calculate aim angle dead zone range

In my top down 2D shooter game the player has a shoulder mounted gun which rotates and aims automatically at enemies - that part is all working fine. Since the player can rotate as well, the gun is ...
1
vote
1answer
22 views

How do I scale my spell target indicator to match the radius of OverlapSphere

I have a spell system in which some spells have an Area of Effect. To get the targets I use Physics.OverlapSphere. I show the player an indication of the spell's ...
1
vote
1answer
46 views

How do I calculate to and from a Non-Linear Acceleration?

I am looking at non-linear accelerations using the following values: initial_acceleration time_to_max_velocity max_velocity current_velocity Initial_acceleration is the per frame acceleration we ...
0
votes
1answer
31 views

Isometric tiles on wrong positions if the mouse points at a negative world coordinate

I am using this approach: http://clintbellanger.net/articles/isometric_math/ Basically, you can calculate the iso coordinates based on the screen coordinates. What I am doing is, getting the actual ...
2
votes
1answer
30 views

Find projectile initial velocity, and air time, given projectile elevation, distance, angle

I have a target X position (D). I have a turret Y elevation (E). Turret is always pointed at 45 degrees (A). I need to calculate the initial projectile velocity required to hit the target, with an ...
0
votes
1answer
52 views

How to rotate velocity Vector3 to always point the same direction so that it can be applied to 2d blendtree?

Given two variables, a Vector3 representing body velocity and a Quaternion representing body's local rotation, how could I normalize the velocity vector so that it's always oriented towards the ...
0
votes
1answer
56 views

Getting angle from current position and next position

I am using pathfinding to move a train along rails, but I need the train to rotate. I have the next intended position and the current position at my disposal, how would I go about this? Pseudocode ...
0
votes
1answer
149 views

How to make good combinations of xp tables and xp rewards?

Is there a known step by step (automatable) to define mean xp reward formula/table to bases specific challenges rewards (generically, not only defeating enemies) and total xp table that set character ...
0
votes
0answers
31 views

How to make a dynamic frontline system for my game?

My problem: Basically the units, units meaning soldiers or vehicles, influence the frontline by moving into the opponents territory (See example image). I'm trying to understand where to even start ...
0
votes
0answers
23 views

Why does this order of Quaternion multiplication not introduce roll into my fps-style character controller?

I'm working on an OpenGL based project (in C#), employing Quaternions to rotate my camera I first tried to: ...
0
votes
0answers
40 views

C++ Help with Separating Axis Theorem

I am trying to detect collision between two triangles using Separating Axis Theorem however I am unaware what is wrong with my code. The CollisionHelper::isTriangleIntersectingTriangle is called every ...
1
vote
1answer
38 views

Using enemy, player and gun position can player shoot enemy?

I was asked this question in an interview last week and I've been thinking about it but I'm unsure how to solve it. You are on a spaceship and want to shoot the enemy space ship. You have the enemy ...
0
votes
0answers
16 views

Formula to calculate Level and Current Experience from Total Xp [duplicate]

So I'm building a mobile game where I have simple XP progression system that goes like this: Level1: 0-399 Total XP Level2: 400-1199 Total XP Level3: 1200-2399 Total XP So basically for the first ...
0
votes
0answers
25 views

Upside down ground correction?

How would you go about making ground correction for a platformer but upside down(reversed gravity)? I used this formula: P.Y+=(P.Y-2)%8-1 but the character just ...
0
votes
2answers
126 views

How to check if two normals/directions “look at” each other?

I need to flip polygons in my application. How do I determine if two vectors face each other, like in the second image below? Note that the origin of the vectors is also important, in addition to the ...
0
votes
1answer
61 views

Getting points inside a circle with a given radius in a 2D array?

Let's say you have a system that removes everything within a square made up of 4 position points. This square is calculated by taking the center point and adding or subtracting the range from this ...
0
votes
2answers
25 views

Math: determining a proper procedural vector for sine-movement

My Problem Suppose you have an object moving along the x-axis, wobbling up and down. Movement code might look like this: x += 1; y = Sin(x); Move((x,y) * speed); ...
2
votes
1answer
49 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 ...
0
votes
0answers
23 views

Calculate the starting position of a turning aircraft with inertial force to make it stop at desired position and heading

Continued from the answer here, I have some problem when the aircraft in my game has inertial forces after going forward and turning itself. To illustrate, from the following image (https://imgur.com/...
3
votes
0answers
82 views

Calculate the aircraft's movement path in which its side speed is required

I am working on an implementation problem in which given an aircraft and the objective of the system is to find the quickest route (optimal in terms of time) from point A (contains the information of ...
2
votes
1answer
56 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 ...
2
votes
1answer
87 views

Rotate Object in world space - Raytracing

I’m programming a C raytracing project. I’ve been wanting to implement object rotations (square, cylinder) for several days but I can’t do it. For each object I have its position (x, y, z) in the ...
1
vote
1answer
82 views

Damage-calculating formula for turn-based RPG with a twist: I have developed a formula, do you the experts think it will scale up successfully?

I’m developing a turn-based combat system for an RPG. It’s a little different to your standard RPG though. The idea being, the faster the player solves the problem they are presented with each time it'...
0
votes
2answers
26 views

Getting the edge-cells in a list of cells on a 2d grid, and knowing which neighbor is missing

I create a "circle" on my 2d-grid using this code: ...
2
votes
1answer
66 views

Diamond shaped map: converting tile number to coordinates and back

I have a diamond shaped map that is displayed as follows: ...
2
votes
2answers
208 views

LibGDX Efficient way to reduce a vector's value gradually until it reaches 0,0

I can manage to achieve this but the code seems to be much longer than it should be. Velocity is given an initial value, either positive or negative and then is ...
1
vote
0answers
59 views

My arcball camera does a roll when it shouldnt be

I am trying to build an arcball camera and it's mostly working, the problem is that as you rotate around the object you have selected (orbit_target_pos in the code),...
0
votes
0answers
65 views

Trying to 'stamp' an arbitrary assortment of pixels to a texture2d that may be rotated at an arbitrary angle

This one is hard to explain but I'll try to not to overcomplicate it. Engine is Unity, for reference. I have a system where an object has a 2d texture to display a custom splat map. The user can '...
2
votes
1answer
89 views

Clamp quaternion relative to plane normal

How would one be able to clamp a quaternion based on the angle relative to a plane surface (defined by a normal)? My diagram below provides more of a visual explanation of exactly what I am talking ...
3
votes
1answer
107 views

Rotate quaternion around plane normal

How can one rotate a quaternion so that the rotation is around a plane normal? A graphic/diagram I made below gives more detail about what exactly I am implying. Note that the tip of the quaternions ...
0
votes
1answer
63 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 ...
0
votes
1answer
78 views

Need Help Figuring Out Damage Calculations for Diablo RPG Clone

I'm building a Diablo clone using Unreal Engine 4 and have been having trouble wrapping my head around how the combat calculations should work. I copied a lot of the core stats from the original ...
0
votes
0answers
18 views

tilemap movement bounderies

My active tilemap surface is 5x5 tiles, and I try to limit the player's movement inside this area with the following code: ...
0
votes
0answers
38 views

Advice for a table top rpg with rpg systems

English isn't my first language so sorry in advanced for odd wording. Idk if this is the right type of form but,I would like to make a game much Like D&D. With that said basic attacks seem to ...
0
votes
0answers
16 views

Spawning objects inside rectangle JS

I'm making a JS game "Monopoly", where I spawning players in random position inside a rectangle. I need a formula that spawns circles INSIDE a rectangle, without being outside. Here what I have tried:...

1
2 3 4 5
35