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

How to slowly rotate a graphic over time as it moves toward target?

This is the code I am working with. I feel like I am close, but I can't stop the graphic from turning. How do I stop the graphic from spinning continually? ...
0
votes
1answer
46 views

How to place a camera so that it always fits a plane?

I have a plane that can get its scale changed during the game, and I want to make the camera view it completely every time the plane has its scale changed. The only camera is set to perspective ...
0
votes
1answer
38 views

How to calculate the transformation such that two points with different position, orientation and origins line up?

Let's say you have two different 3D Objects which both contain a node that is off center (not at the origin) and have an orientation. How do you calculate the transform for one of the object so that ...
0
votes
0answers
23 views

Tilt car to accomodate for larger Tire

I would like to rotate the car so that the front wheels are touching the ground without using physics. As you can see i want to rotate the car by angle a, but making sure that both tires are touching ...
0
votes
1answer
24 views

Trying to rotate a point around another point and it's not working

I am trying to make a function to rotate a point around another point. My maths are very rusty but i did some research and i just dont understand why my function is not working. ...
1
vote
0answers
39 views

Orthographic camera produces strange results

I've created a basic orthographic camera using the following view projection matrix: ...
0
votes
0answers
27 views

get closest unobscured point on bounding box (to point)

I know that I can get the nearest point on a bounding box to a point by clamping the coordinates of the point to the bounds of the bounding box. However, how do I get the nearest point on a bounding ...
0
votes
1answer
51 views

Calculate Discrete Fourier Transform by using c#

There is a definition of Discrete Fourier Transform: I want to calculate amplitude and phase of a transformed sequence. I tried : ...
0
votes
1answer
7 views

Unity - Set rotation of object using angle between two points?

I have a LineRenderer that draws a line between two points, Vector3 startPos and Vector3 endPos. How can I get the angle between these points, and apply it to an objects transform rotation, so that it ...
0
votes
0answers
9 views

Rotate to face the bottom of a unit towards a planet [duplicate]

I would like to have tanks that move around on a planet (a sphere). Depending on where the unit is, I would like it to always have the bottom of it facing the center of the planet. To do this I've ...
0
votes
1answer
28 views

How to change the up vector of something in Unreal

I'm creating a grapple hook mechanic. The elements of this particular situation are a Player and a grapple point. I would like the top of the player to always be pointing towards this grapple point. ...
1
vote
0answers
72 views

Calculating spaceship course

There is an idea for (soft) sf strategy game following me for a long time but I need to get a grasp of some math before moving further with it. Lets assume there is a spaceship traveling (in space) ...
0
votes
3answers
62 views

Finding an angle between two bodies

I am trying to find angle between vectors a and b. But the cosine for some reason is not within +/- 1, that means that it is not possible to find an angle between a car and a pedestrian... Any help ...
0
votes
0answers
13 views

Map an equirectangular square slice inside cubemap

I'm trying to map a square slice of an equirectangular image inside a cubemap with 6 faces, without distortion. The point is that I'm dealing with huge array sizes if I try to project the whole ...
0
votes
1answer
43 views

Rotating Sprite Around A Point Without Messing Its Drawing Point

I am trying to draw and rotate an arrow sprite based on a point,around a static circle body without messing its drawing starting point. Arrow should be directed to the same direction with user touch ...
0
votes
1answer
56 views

how can I transform a skewed line to a vertical line?

So, I have a line: And I skewed it with x += y * cos(angle) and got something like: My question is, if I have another line segment with that same skew, how can I ...
0
votes
1answer
44 views

Rotating a parent rectangle to align child with target

My beautiful drawings will explain better than many words (or at least I hope): The structure: The black rectangle is a GameObject (my weapon sprite). A and ...
0
votes
0answers
33 views

Grappling hook force resolution

Our team is creating a 3rd person adventure platformer in Unreal 4.22. One of the mechanics is a grappling hook. Think less-so a 'pull-to-point' grappling hook (Widowmaker, Just cause etc.). However ...
0
votes
0answers
48 views

Convert Flat World Angle into Isometric Angle?

My game is isometric 30 degrees (think Diablo 2), I'm looking to convert the angle A1 from the player tile A to the destination tile B into the appropriate angle A2 in the isometric view. For the ...
0
votes
0answers
34 views

Concept design-pattern for industry simulation required

I am making a mobile game simulating industry. A brief high level description is below. A hub could be thought of as a base/city, within which there are rooms/buildings which determine what is ...
0
votes
1answer
97 views

Mana regeneration formula

Suppose my mana regeneration rate was calculated in this way: ManaRegenRate = 0.01 × (BaseManaRegen + ManaRegenMultiplier × Willpower) × TotalMana Where willpower is my attribute ranging from 0 to ...
2
votes
2answers
96 views

Catan Optimal Placement

Is it possible to calculate the best possible placements for settlements in Catan without using an ML algorithm? While it is trivial to simply add up the numbers surrounding the settlement (highest ...
0
votes
0answers
29 views

What is a good algorithm for generating a linear regression of positions in 3D space? (for getting the direction of a thrown object in VR)

I'm trying to get throwing to feel right in my VR game. I don't plan on actually using physics to do this; my idea is to accurately determine the lateral direction of the throw, then move the object ...
1
vote
3answers
188 views

WoW attack speed calculation

Reading up on attack speed calculations for World of Warcraft I noticed that the formula for attack speed is: Attack_speed = "current attack speed" / (("Percent increase or decrease" / 100) + 1 )...
0
votes
0answers
34 views

Combining rotation (using Quaternion* Quaternion) doesn't work as expected [duplicate]

I have fragment of code that has to rotate the camera to the direction where my cursor is as below: float yaw = mouseSensitivity.x * Input.GetAxis("Mouse X"); float pitch = mouseSensitivity.y * -...
0
votes
0answers
20 views

Calculate direction of object to intercept moving object between two points [duplicate]

Please have a look at this graphic: I need to calculate the direction of B in order to intercept Z between A1 and A2, if possible. Both, Z and B start at the same time. Can anyone help me with the ...
1
vote
3answers
116 views

Should calculations be done on the CPU or GPU?

I'm currently learning OpenGL and it's become obvious that I can do most calculations on the CPU or the GPU. For example, I can do something like lightColor * objectColor on the CPU, then send it to ...
1
vote
0answers
60 views

The Google Earth solution for panning in a 3D world

About a year ago I made a solution for panning and zooming in a 3D world (Three.js) using a formula provided by @DMGregory. Here is the post: How to panning camera on XZ axis with different angles ...
0
votes
2answers
33 views

Get Closest point between a Box 3D and a Point

I have a point A (x, y, z), and a Box: Center (x, y, z), Size (Width, Height) How to get the closest point in the box from the point A ? In Unity I can create a bound, and I can find the non-rotated ...
1
vote
3answers
55 views

How to find perpendicular line given a line?

I have two points that form 1 line. I want to find a point that creates a perpendicular line. Here is an image showing what I am looking for: How do I find the red point to form a perpendicular ...
0
votes
0answers
24 views

Camera rotation to match UVs of a point across different FOV

I'm looking for the formula needed to calculate the amount of camera rotation required to display a point at the same UVs across two cameras with different FOVs. I can't modify the projection matrix ...
1
vote
2answers
76 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 ...
4
votes
3answers
116 views

How to calculate the reachable space of the end effector in an IK chain?

I have an array of points in a 2d worldspace and I want to calculate which points are reachable by the end effector of a limb controlled with a CCDIK chain (with rotation limits applied). It's a limb ...
1
vote
0answers
27 views

How does displacement mapping generalize bump mapping?

This PDF discusses bump mapping, a special case of displacement mapping. A surface is represented as a function \$\overrightarrow{O}\left(u,\,v\right):\:\Bbb R^2\mapsto\Bbb R^3\$. In bump mapping, we ...
1
vote
1answer
30 views

Find the direction a Projectile should be fired from a Moving Object to hit another moving Object?

I am trying to do a simple AI Controller, which fires Missiles at the surrounding targets in the Scene. The AI Controller can fire projectiles when moving or stationary. The Targets are either ...
3
votes
1answer
90 views

How do I get an object to rotate in world space via RigidBody.AddTorque?

I'm getting really discouraged because I can't seem to figure how how to rotate my object via Rigidbody.AddTorque like it is on a figurative global turn table rather than a local turn table. Another ...
0
votes
0answers
24 views

Calculating stopping distance while turning

I need to calculate the movement of an object that is slowing down to approach its destination while turning. Calculating the linear stopping distance and deceleration is straightforward. However if ...
-2
votes
2answers
99 views

Converting a table into a formula / equation

I need help to figure out the formula / equation or at least the growth rate based on this table. All I can see is that the base stat is 12 as STAT2 = 2 x base and STAT3 = 5 x base.
1
vote
1answer
47 views

Camera Transition between 2 position / rotation, and follow a 3rd target

I have setup a transition of camera between 2 transform, here the result in video: https://youtu.be/rcwQ6KuEfMw I have the information of the 2 transform: - position (vector3) - rotation (Quaternion) ...
0
votes
0answers
22 views

Converting a multidimensional array to a distance field

I've been working (as so many others before me have) on a small Voxel-type game prototype. So far, i have a 3d array (16 by 16 by 255 elements) that contains block ids - and as of right now, 0 means "...
0
votes
0answers
26 views

Account for scale offset?

I have an odd situation where I know the position of an item on a mouse click and I know the panning state of a 2D camera pointing at it. So what I do is render an object at the point in which the ...
2
votes
1answer
53 views

Quick way to approximate a truncated gaussian distribution?

I'm doing some procgen stuff and I need a truncated gaussian distribution. Basically, I need a way to get the same thing as this: ...
2
votes
1answer
71 views

How to draw a string into a polygon? (Libgdx, Java)

I am working on a 2D grand strategy game (like Hearts of Iron from Paradox but as I said only 2D game) and I would like to render the area names on the map. I made the Polygons for each area. How can ...
1
vote
1answer
46 views

How to calculate more precisely the position of the pupil in function of the eye ball and a direction?

I have a game in which I have an eye in a head that should always move towards a piece of food (or another piece of food). The head is moved by the player. The food has a fixed position (for some ...
0
votes
0answers
22 views

Need help to find a way to make a image mapping

I need some help to find a way of creating a simple game in any language/software/technology. What I have to do is to map a png image in order to create a correct "path" for a player so he can make ...
1
vote
0answers
19 views

Can I slightly rotate a 2D vector (UV Edge) to more closely reflect the corresponding 3d vector?

I'm trying to get the difference between the 3D angle of two connected edges and their corresponding angle in 2D (mesh to UV space). I would like to slightly rotate the angle in 2D to closer match ...
0
votes
1answer
25 views

Clamp GameObject Into Isometric Camera Viewport

I'm using the next code to move an objecto into an isometric projection (30/45) ...
2
votes
1answer
84 views

Modeling complex requirements for populating loot/drop tables

I have a set of items and a data structure that describes where and how those items may be dropped. I'm looking to implement a roguelike/randomizer element to the game and want to include the special ...
0
votes
1answer
63 views

Mapping a Texture to a 2d Quadrilateral

I want to map a 2d picture onto an arbitrary 2d quadrilateral, for the purpose of particle system. To do that, I split the picture into two triangles, and then linearly interpolated u,v along the ...
0
votes
1answer
57 views

Calculation of distance while switching between two speeds

There are two speed values, that are used by moving object. After a while speed switching occurs from V1 to V2. I need the formula that can be used for calculation of current distance (at specified ...