Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [mathematics]

Mathematics questions deal with the arithmetic, geometry, calculus, formulae and other calculations used in the development of a game.

1
vote
1answer
48 views

Math needed to create a very simple 2D side view car game

I'm trying to create a 2D side view car game (something like Hill Climb Racing, but much more simpler), but I'm confused on the math and physics. Most of the tutorials I found were about making a top-...
0
votes
1answer
23 views

Understanding the “gradient” in Perlin Noise

If I didn't get it wrong from the wikipedia, the word "gradient" should represents either the derivative for continuous functions, or the differential for discrete functions. To rebuild the original ...
0
votes
1answer
18 views

How to scale a sprite on x axis to touch the point without changing pivot?

I have a sprite. The pivot is at random point. I want to increase the sprite's scale on the x axis, without moving the pivot, until its edge touches a point at right. I have a method to set/add size....
0
votes
1answer
18 views

Rotating on a slanted surface?

I want to rotate (change it's yaw) an object when its sitting on slanted ground. Pretty much I want to rotate around the ground's normal. Right now I ray cast down, get the ground's normal. Then I do:...
1
vote
0answers
20 views

Circle ceases to be a circle when radius is below a certain value

I'm using the LineRenderer component to draw a circle. It renders fine, but it's a little too large. The smallest I can set the radius is .06f. If I try to set the radius to anything less than that, ...
2
votes
2answers
50 views

Midpoint displacement generating unsatisfactory terrain

Following this lesson for implementing mid-point displacement algorithm for terrain generation. I aim at generating a wavefront(obj) file of the terrain I have an array of dimension (2^n + 1) x (2^n +...
1
vote
1answer
56 views

Algorithms for Automated Game Levels Creation ( 2D )?

I am trying to algorithmically create a game like the one in the picture below I am trying to Create random levels from an algorithm. Ideally, the algorithm will take into account the desired ...
0
votes
0answers
18 views

From look-at vectors to a quaternion

So, I have code to create a quaternion from a matrix (using the 3x3 rotational part.) And I have code to construct a transformation matrix from a lookat + up vector pair. To go from lookat+up to ...
0
votes
1answer
27 views

How to get the tangent and normal of a collision?

In my game, one of my objects casts a ray into a 2d space. If that ray were to hit another object, I'd like to draw a line that is perpendicular to the tangent of the ray's hit point. So when the ray ...
3
votes
1answer
57 views

Octahedral impostors, Octahedral mapping

I'm facing some issues understanding this article about octahedral impostors. More specifically I quite don't understand how one can map the hemi-octahedron (subdivided) vertices to texture ...
0
votes
2answers
39 views

How to calculate turret position after rotation

I'm trying to make a tank character for my game but I couldn't do the math of firing bullets from turret instead of center of the tank. I tried some Stack Overflow solutions but I couldn't understand ...
1
vote
0answers
56 views

algorithm to change the center of the image

I need and algorithm in Java if possible to change the center of the image when scaling.What is happening to me is represented in the first image: when I scale the image the image scale according to ...
0
votes
0answers
25 views

creating levelup stats based on curves [duplicate]

I'm creating a simple level-up system and I'm looking to base the stats gain on curves so I can tweak them easier, I know it's a math function, but I have no idea what to search for. I need to create ...
0
votes
0answers
32 views

XMMATRIX performance

Dears, I am facing a performance problem when I try to access cell 42 and 43 in XMMATRIX define in DirectXMath.h. The frames dropped by 100 FPS. Here is my code: ...
0
votes
0answers
19 views

Get Position and percentage of a given point on a Spline

I have a spline data, in a List chunkPath; and a player position (x, y, z). I would like to get the closest point in the path, and get the actual percentage we are inside the path... So What I have: ...
6
votes
0answers
108 views

How to move a portion of bezier/spline curve along its complete bezier/spline curve?

Based on the image below, I have a curve (orange) which is a bezier sub-curve of an original curve (longer black curve). The original curve consists of a number of cubic bezier curves joined together. ...
0
votes
2answers
71 views

Calculating the intersection of a fast moving circle and a line

Inside of my game, I am in need of a way to test the collision between a line segment and a fast-moving circle. I would say I need a line v capsule collision however the problem is I need the ...
-2
votes
1answer
63 views

How to move a 2D boat in unity

I am working on a 2D game in which boat moves continuously but the direction of the boat is on users touch. Where the user moves its finger the boat moves in that direction. How would I achieve this? ...
0
votes
2answers
42 views

Having two points (line) how can I substract a specific amount to each point?

I have two points that make a line. And I need to subtract a specific amount to each point keeping the direction of the line. I know the radius which is the amount to subtract. The red dots of the ...
1
vote
1answer
49 views

Distance function on a pacman plane

I am making a game, where if you go through the right wall, you pop up on the left. I want to have a function that calculates the distance between two objects, where we can have a line that goes ...
0
votes
1answer
39 views

OpenTK OpenGL wierd camera look

I am trying to implement a simple camera mouse look. ...
1
vote
1answer
80 views

Redundant checks from spatial partitioning

A simple 2D grid partition system for collision detection divides space into equal-sized tiles. Colliders then map themselves to tiles with their bounding box in O(1) time. Collision detection only ...
0
votes
0answers
16 views

Simple Automation of Car Path Finding Between 2 Points [duplicate]

I would think that it would be simple to have a car drive from A to B, but apparently I haven't been able to figure it out. My goal is to have a car begin at a certain position and angle, calculate ...
0
votes
0answers
27 views

How to convert a rotation around an axis into pitch and yaw rotation

So i want to rotate particles towards a point and i've already figured out how to calculate the angle and the rotation axis. Currently what i do is simply use a 3 dimensional matrix, apply the ...
0
votes
1answer
52 views

Orbital rotation equation

I am developing a space sandbox (3D). Now I am working on an asteroid belt around a planet. I have an Asteroid class and an ...
0
votes
4answers
112 views

Operating Expenses of Mathmetic Operations

I understand that math operations require more resources/take longer than others when being computed. (e.g. square roots take longer than divisions which takes longer than multiplications which takes ...
1
vote
1answer
76 views

How to move points of a multi-segmented bezier curve to one side

I am trying to move points from a multi-segmented bezier curve to one end of the curve using the following code which modified for my use from here. Only the last segment seems to give the desired ...
0
votes
1answer
70 views

Get a Jump normal gravity based on Attractor Points, lines or Quad placed in the Level Design (in a Mario galaxy like gravity)

I have an algorithme to find. I have a player in a 3D space on a random planet. My goal is to have an oriented gravity toward my planet. And when I jump: Find the right normal direction. BUT I can't ...
0
votes
1answer
40 views

how do I move an object based on rotation of another object?

This question is related to my other question about camera rotation. I hope its acceptable to ask a second question. I cannot figure out the math of how to calculate moving the camera to stay behind ...
1
vote
1answer
44 views

Sum of FoV enemies

so what I need is to calculate the sum of players' Field of view. Put simple, In a 2d space, I want to check how much they cover (in degrees). So here are a couple of use cases to explain by example: ...
0
votes
0answers
31 views

Frequency-based ELO rating

To replace the context, you probably heard of the recent new game Apex Legends. If not, it's a battle-royal game where 20 squads of 3 players compete to be the last team standing. So in the end of a ...
0
votes
1answer
27 views

Move camera around player while facing player

My player has the following hierarchy: Hero (GameObject) Model (child of "Hero", centered at 0-0-0) Camera (child of "Hero") The camera should be ...
3
votes
1answer
122 views

How to move bezier curve points along circle to form a symmetric curve at center

From the image below, A is an open bezier curve with it's points positioned to represent a circle. AP3 and AP1 have the same position. From B, How can I move the points (AP1 and AP3 along the bigger ...
0
votes
1answer
66 views

How do I move an object in a square pattern?

I have some bots that can move via setting the x and y. I have already been able to make them move in a circle pattern, but how do I make them rotate around the player in a square pattern? I'm not ...
0
votes
0answers
25 views

Swapping Axis by Swapping Matrix Rows

I'm using MathGeoLib, which uses row-major storage. The problem that I'm facing is that I'm going from a East-North-Up(ENU) coordinate system. And I need to go to an East-Up-North(EUN) coordinate ...
4
votes
1answer
118 views

How can I find the distance from bezier curve anchor points to control points for a circle approximation and their positions

From the image below, I have represented a circle by a closed bezier curve made of two cubic bezier segments. I am aware that a bezier curve cannot represent a perfect circle. How can I calculate the ...
3
votes
1answer
110 views

How to efficiently (no pointers) store hex grid with shared edges and vertices?

I have a hex grid stored in a 2d array; now I want to add some properties to the edges of the grid (e.g. rivers between hexes) and also potentially to the vertices. How can I store edges and vertices ...
0
votes
0answers
114 views

Find transformation to align two polygons at fixed points?

Problem I have a source image (arbitrary width and height c) shown here as a rectangle [X1,X2,X3,X4]. It contains two points C and D (both known coordinates within ...
0
votes
1answer
47 views

Raycaster calculation question

I am following this tutorial https://lodev.org/cgtutor/raycasting.html When deriving deltaDistX geometrically you get, with Pythagoras, the formula "sqrt(1 + (rayDirY * rayDirY) / (rayDirX * ...
2
votes
1answer
74 views

How to determine polygon based on point lists?

I have several lists of interconnected points. They are ordered so I can connect them together. Using these interconnected points I'd like to find the different points and intersection points that ...
0
votes
0answers
22 views

Optimal way to select a random item from a list based on its chance to appear in Unity [duplicate]

I am creating a random object spawning script in Unity with c#, and am wondering what the ideal way to do this task would be. So I have a list of 31 objects or so, of my special class type. Each one ...
1
vote
1answer
65 views

Difference between two perspective projection representations

When researching perspective projections on the web, I've come across two different representations. One is unrelated to OpenGL and the other is strictly associated with it. What is the relation of ...
0
votes
1answer
36 views

Move a point to another, along an elipse

according to this picture, I want to move my yellow object, smoothly to the red one. And I want to have an eliptic trajectory in relation to my center point. So for now I'm having this code: ...
0
votes
1answer
54 views

How to find 1/3 and 2/3 of the distance between two given points?

I know how to find the middle of two given points: var midpoint = (pointA + pointB)/2; where pointA and ...
1
vote
2answers
125 views

How to calculate suitable attack speed

I'm developing an RPG and am stuck trying to create a formula for attack speed, using four stats and a base speed. Basically, I'm trying to get an outcome where the encumbrance (basically weight and ...
1
vote
1answer
47 views

How do I find the downward sliding direction of a plane?

first time poster. I'm curious as to how I can obtain a vector that defines the downward slope of a 3D plane. The goal is to apply this to a player as a force to achieve a sliding mechanic, like in ...
0
votes
0answers
18 views

combine two translation/rotation/scale triplets without matrices

Let t1/2, r1/2 and s1/2 be two sets of transformations. Translations are vec3, rotations are quaternions and scales are vec3. Lets assume that all common operations are defined (overloaded operators ...
4
votes
0answers
45 views

Slot Probability Function

Please can someone point me in the right direction. I'm working on a slot game. that I'm having trouble figuring how to implement the probability function for. The game has a set of symbols that bets ...
0
votes
2answers
244 views

Algorithm to detect impossible scenarios

I'm making a simple game where a surface is split up into 4 parts, rows, obstacles spawn in them, and a player tries to dodge them. Up to 3 obstacles are generated in each row, and this can lead to ...