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

How to apply a color transform to textures when using pre-multiplied alpha?

I'm trying to apply a color map to my textures. The map is a 4x4 matrix that adjusts the contribution of each RGBA channel returned from the fragment shader. My texture needs to use pre-multiplied ...
0
votes
1answer
14 views

How to sort scores and assign positions based on the scores?

I have three game objects each with a score. I was wondering how I'd go about sorting these scores in ascending order. I want to also give these objects a position based on their score. Any help would ...
0
votes
0answers
18 views

How to transform coordinates to ellipsoid space?

I am trying to implement the 3D collision detection algorithm from: http://www.peroxide.dk/papers/collision/collision.pdf The paper covers converting R3 world coordinates into eSpace before running ...
0
votes
1answer
27 views

How to make controlled exchanges in an online-game?

There is an online game in which you can collect things of different values: ordinary, epic, legendary. The cheapest things are ordinary, the more expensive are epic, and the most expensive are ...
1
vote
1answer
26 views

How do you draw a random irregular polygon in java? (Asteroids)

I am coding an Asteroids game in Java. In the real arcade game, asteroids are made of irregular shapes like this: When I code, I can only set asteroids to 1 or another specific shape, like this: ...
0
votes
1answer
76 views

Bouncing Ball in c++

Background I've been making my own game from scratch. I've made my own collision system and there's a situation I'm having an issue with. Problem Pictured: a ball going in one direction and ...
0
votes
1answer
26 views

Calculation of perpendicular distance to camera plane explanation

I am following this tutorial for a Wolfenstein 3D engine. https://lodev.org/cgtutor/raycasting.html Here is the relevant image from the tutorial: I cannot figure out how dividing by rayDirX or ...
0
votes
0answers
29 views

Is there an easy way to calculate the velocity of an object on a pendulum?

Want to have a rope travel to the mouse on m2 click and then act as the pivot of a pendulum, with the player being the bob. Used some math I don’t really understand to get the angle of the mouse ...
2
votes
1answer
84 views

How to determine the cost of new units

Suppose I design a game such as Battle of Wesnoth, where there are many races, each of which with many types of units. Is there any rule-of-thumb for determining how much each unit should cost? One ...
0
votes
0answers
23 views

Finding the site of the potential collision between 2 vehicles

I've been trying to implement the unaligned collision avoidance steering behavior. I get what needs to be done on a high level, but struggle with the maths behind it. On Craig Reynolds site, he ...
0
votes
2answers
62 views

How does lookAt matrix math work?

Can someone provide me an explanation of how the lookAt matrix works? ...
0
votes
2answers
73 views

What is Unity Quaternion range?

I've read somewhere that a Quaternion in Unity ranges between [-1,1] values. I mean the individual XYZW values. Ex: new Quaternion(.1f,.2f,-.3f,-.4f) Is this true? More clearly: I know they take ...
0
votes
0answers
72 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 ...
1
vote
1answer
32 views

How to calculate plane corner vertices from plane origin point and plane normal?

I have an origin point, and normal vector of a 3D plane. I want to calculate 4 vertices to use as the corners of a 2 triangle quad to render the plane.
0
votes
1answer
52 views

Simplifying Camera Strafing

I have a camera that follows the position and direction of the player. These are updated using spin and velocity. The velocity is updated like so: ...
1
vote
1answer
38 views

Calculating 3D character movement based on YAW and Pitch

I'm not sure how to calculate an XYZ immediately to my characters left based on the direction they are facing. I am learning to create a 3D game in Monogame on top of .Net Core 3.1 in c# using ...
0
votes
1answer
56 views

Confused about why my projection matrix works

My projection matrix was buggy, I'm not great at mathematics, but I checked it against the the songho tutorial, and the broken one seems correct to me but switching nearplane to farplane seems to ...
0
votes
1answer
28 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 ...
1
vote
1answer
93 views

What are spline input keys?

There isn't a really adequate explanation of these anywhere on the internet, so I thought I'd ask this question here. What are spline input keys in Unreal? How are they represented in Unreal? Also: ...
1
vote
1answer
72 views

How to apply linear drag to a velocity vector?

I have built my own movement code for my character as I want to make smooth movement. (This project is just a character and a floor/wall for testing). The code seems to work fine, but I of course ...
0
votes
0answers
57 views

How do I prevent camera jitter when rotating the player - Unreal?

This is a problem that seems to have no reasonable answer anywhere around, yet is a commonly needed aspect of developing game mechanics. Context I'm developing a traditional 3rd person character ...
1
vote
2answers
30 views

How to get chunks in a sphere rather than cuboid

I have a chunk system to load stars around the player. It takes a given "real" loading range (aka Unity-units of range), calculates the necessary chunk loading range (as integer), creates star ...
52
votes
4answers
9k views

How are imaginary numbers useful in video game creation?

I learned about imaginary numbers in school and they seemed so impractical, so I asked my teacher what they were used for and he said "video game creation". I just want to know if this is true and ...
0
votes
0answers
26 views

Understanding Parametric UV's?

I've watched a video on Parametric UV's but I cannot understand how to calculate, the Parametric UV's on a flat surface or a sphere. Should I perceive Parametric UV's the same way as a UV map, which ...
0
votes
0answers
9 views

How to fix roll in FPS camera when looking sideways [duplicate]

I am trying to calculate the rotation for an FPS camera. My closest attempt was to create a some Euler angles(from input) and multiply that with the view matrix, this works, but only if I am looking ...
1
vote
1answer
172 views

The view matrix finally explained

I must say that I am really confused by how a view matrix is constructed and works. First, there are 3 terms: view matrix, lookat matrix, and camera transformation matrix. Are those 3 the same, or ...
0
votes
1answer
40 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 ...
0
votes
1answer
76 views

I need an analytic formula for 3 arms inverse kinematics system

I need an Analytic formula for 3 arms IK system_. I'm currently using Fabrik and CCD solutions but I'm facing low-performance and accuracy issues. So now I'm looking for an Analytic formula. I'm ...
0
votes
2answers
128 views

Why are rotations in 2D game engines often counter-clockwise = positive systems?

I was looking over the API for a game engine a friend was developing in her spare time. She made the decision to make positive angles rotate in a clockwise direction. This immediately struck me as odd....
0
votes
1answer
116 views

THREE.JS - How to know the shortest rotation direction an object must do to look at other?

I am trying to understand a way in THREE.JS (and the mathematical foundation) to get the direction an object should rotate to lookAt other but without actually rotate it. I've tried to use ...
2
votes
1answer
64 views

How to align a 3D object with four points?

I'm sure there's a better way to articulate this question, but I lack the vocabulary. Imagine a skateboard. As it rolls straight down a road, the "deck" is aligned with the road, just offset a few ...
0
votes
1answer
59 views

How can I match the delta rotations of two objects?

Here is the code I'm starting from: ...
0
votes
1answer
57 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
45 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
26 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
29 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. ...
2
votes
0answers
46 views

Orthographic camera produces strange results

I've created a basic orthographic camera using the following view projection matrix: ...
0
votes
0answers
31 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
57 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
39 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
34 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
75 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
70 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
20 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
48 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
59 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
45 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
53 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 ...

1
2 3 4 5
34