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.

28
votes
6answers
19k views

How do idle games handle such large numbers?

Just wondering how games such as Tap titans and Cookie Clicker handle such large numbers. I am trying to implement an idle game however the largest number format supported by C# is decimal. I am ...
45
votes
7answers
11k views

Moving ships between two planets along a bezier, missing some equations for acceleration

OK, I already posted this over at math.stackechange.com but didn't get any answers :( First of here's a picture of my problem, the description follows afterwards: So I got all the points and ...
0
votes
0answers
12 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: ...
1
vote
1answer
70 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 ...
3
votes
0answers
37 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
48 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 ...
0
votes
1answer
80 views

Combine rotation XZ (horizontal) with YZ (vertical). Math formula

I'm trying to make a rotation vertically and horizontally around a point at the same time but I'm not able to combine both. I have this formula for the horizontal rotation: ...
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 ...
20
votes
1answer
2k views

How can I evenly fan out a hand of cards?

Given a set of playing cards (rectangle images with a width and height) how can I rotate and position each one so that they appear in a 'fan' pattern, much like you would hold a hand of cards in real ...
-2
votes
1answer
60 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
3answers
496 views

Tile detection on a 2D isometric layered diamond shaped map - What are the math?

What are the math for tile detection on a 2D isometric layered diamond shaped map ? Here is an image of a layer (this is an image from an old folder, I didn't write the display yet for my current ...
1
vote
2answers
55 views

Timed Line Drawing

I'm trying to program a remake of the classic Missile Command Atari game from scratch, but I've run into a problem. So I have a function that can draw a line from one point to another. I figured I ...
1
vote
1answer
76 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
2answers
41 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
47 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
37 views

OpenTK OpenGL wierd camera look

I am trying to implement a simple camera mouse look. ...
0
votes
1answer
41 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 * ...
0
votes
2answers
856 views

Implicit Functions and extracting an isosurface

I recently discovered a paper on Dual Marching Cubes which produces a much reduced poly count to other methods like Dual Contouring and Marching Cubes, however a recurring theme when reading these ...
1
vote
1answer
427 views

Computing the UV coordinates of a 3D point that lies within a 3D triangle

From a triangular mesh I have a 3D triangle T represented by 3D vertexes v0, v1 and v2. Each vertex has an associated UV coordinate into a common texture image, represented as uv0, uv1, uv2. ...
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
1answer
31 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 ...
1
vote
0answers
22 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
4answers
109 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 ...
2
votes
4answers
3k views

RPG Chance to Dodge formula

A friend and I are trying to develop a “chance to dodge” formula that will scale from level 1-1000. I would like to see if one formula can be utilized, using a difference ratio between Character A’s ...
0
votes
1answer
68 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 ...
3
votes
1answer
112 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 ...
4
votes
1answer
112 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 ...
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
1answer
31 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 ...
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
7answers
2k views

Calculating damage reduction of armor parts

I am currently implementing a turn-based puzzle/RPG game. The situation now is the following: The player can have up to 4 armor parts: Helmet, Gloves, Trousers and upper-body-armor. I actually planned ...
0
votes
1answer
49 views

draw concave polygon from set of edge points

I'm having troubles trying to rearrange a set of points where each point is part of the edge of a concave polygone. My set of points is not sorted in any order, they are just randomly put in an array. ...
3
votes
2answers
1k views

Quaternion based camera pitch freaking out, and Z-axis drift

This is the code I use to control my (first person) camera's movement and rotation. Translation successfully keeps orientation in mind, so that up and left and such are always in the expected ...
5
votes
2answers
654 views

How to account for acceleration when aiming projectiles?

How do I aim a constant speed projectile to hit a target if there is a constant acceleration vector acting on it? (For example, the wind and gravity from Worms.)
0
votes
0answers
24 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 ...
1
vote
2answers
68 views

Getting Model View Matrix by hand

Right now I'm trying to calculate the model view MAtrix by hand... The App is 2D. I have Somethign like this.. ...
4
votes
2answers
2k views

What algorithm to use to fill a KenKen square board with cages?

I am working on recreating KenKen, a popular math puzzle involving a blank grid that is divided into "cages". Each cage is just a collection of adjacent squares and has a clue which is generally a ...
20
votes
4answers
19k views

Calculating minimum velocity of the projectile needed to hit target in parabolic arc

If I have a point which I want to hit at the end or during a parabolic arc, how would I calculate the needed x and y velocity?
10
votes
3answers
2k views

How do RPGs balance linear damage formulas?

I'm developing a damage formula for an RPG. I've checked many popular titles formulas for reference (Final Fantasy, Chrono Trigger, Golden Sun and Castlevania) and most seem to use linear functions. ...
3
votes
1answer
108 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 ...
1
vote
0answers
108 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
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 ...
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
1answer
64 views

Wrong angles given by atan2

I have a method to calculate angle between two vectors, but it is giving wrong values. here is the code : ...
13
votes
1answer
5k views

How does UVW texture mapping work?

I'm trying to understand the mathematical theory behind UVW mapping. Can anyone explain me how UVW mapping works? Or at least provide me a pointer?
0
votes
2answers
448 views

Position of an object relative to another in a 2D plane

I have two objects, A and B, each of them has a set of coordinates (x,y). How do I understand where is A in relation to B's position? If I where to just check each coordinates I could do it like this:...
3
votes
2answers
1k views

understanding spatial hash function behaviour and Knuth for int64

I implemented open-indexing sparse 2D spatial HashMap, and I'm quite satisified with performance ( ~30-70 CPU cycles to get object at particular location for size ~16 Milion objects ). However, I ...
1
vote
1answer
48 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 ...
4
votes
6answers
3k views

Is there a quick way to determine if a vector is in a quadrant?

I am wondering if there is a quick easy way to determine if a given vector is in a specified quadrant. In the below image, I've define the ranges of the blue quadrants. For example, if I am given a ...