Questions tagged [mathematics]

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

227 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8 votes
1 answer
367 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. ...
NotEveryDay's user avatar
5 votes
0 answers
88 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 ...
MSD's user avatar
  • 51
5 votes
0 answers
482 views

How to target moving object in 2D game

I am working on targeting system for 2D game. Two objects move in space. Each one have Position and Velocity vector. Ship object shoots moving objects in space. Ship can shoot in any direction, but ...
Kacper Kleczewski's user avatar
4 votes
0 answers
506 views

How to implement a pannini projection in opengl?

I have read about the pannini projection, which involves (I think) projecting a scene onto a cyclinder instead of a rectangle. How can I implement this projection in a vertex shader? Blinky is using ...
jokoon's user avatar
  • 5,243
4 votes
1 answer
130 views

Optimizing black and white matrix block drawing

Disclaimer: I am uncertain if this is the best place to post this question, so please advise me of how I can best find the answer if I am doing something wrong. I am asking this question because I am ...
MrNoise's user avatar
  • 73
4 votes
1 answer
154 views

How to make expanding ring with constant thickness?

I need to generate this burst or (donut-shaped) pulse. I'm having a difficult time how to generate such shape. At first, I was thinking of scaling the image but that didnt work out because the line or ...
quinnavery's user avatar
3 votes
0 answers
97 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 ...
IndyKuma's user avatar
3 votes
0 answers
95 views

Force propagation through physic bodies constraints (as non-penetration)

First, some context I'm currently implementing a (well, tiny) game engine using a predictive approach. The idea is to compute when a state change will occur, and only update state at time of the ...
Felix Bertoni's user avatar
3 votes
1 answer
2k views

How can I move a vehicle using speed and steering angle?

I want to drive a vehicle in x and y coordinate area with range from (0,0) to (6000,5000). I am using Visual Components (using Python API). On input I have speed data and steering angle of wheels ...
Haroon's user avatar
  • 31
3 votes
0 answers
38 views

Defining a coordinate system for player residing in another coordinate system

I'm making a game and I wanted to simplify some code by taking advantage of linear algebra. I'm a little stuck. Let's say the player (green triangle) resides in a coordinate system where the x-axis ...
Carpetfizz's user avatar
3 votes
1 answer
2k views

Converting Euler rotation angles from Z up to Y up (Max to OpenGL)

I'm working on pulling geometry and it's transformation from a 3DS Max exported FBX (Z-up) to an OpenGL model format (Y-up). The main problem is I intend to keep the transformations as Translation and ...
Enam Desak's user avatar
3 votes
0 answers
150 views

What is the formula for the collision of two "stretched spheres"?

In Smash Bros Melee, hitboxes aren't perfect spheres or boxes. They are, instead, a shape that looks like a continuous line of consecutive spheres: I.e., the geometry can represented as: ...
MaiaVictor's user avatar
  • 1,180
3 votes
0 answers
319 views

Filling Closed Shapes

Game Engine : Unity 5.1 Developing on Windows 7 Hello, I am using Vectrosity to draw some some shapes on screen run time. I also need to fill these shapes and none of them are really trivial shapes. ...
Gibtardo's user avatar
3 votes
0 answers
514 views

3D Zoom To Mouse Cursor accounting for Change in Camera Pitch

Overview: Simply put, I'm trying to make a zoom to cursor algorithm. This would normally be very simple, but the implementation of the camera is making it difficult. As the camera zooms in and out, ...
Monatrox's user avatar
3 votes
0 answers
165 views

How to aim with a spaceship in 3D considering its angular momentum?

So I have a spaceship and I have 6 degrees of freedom. At a given moment the following vectors are known of the spaceship: Local forward. Local up. Local sideways (may be implied from the previous ...
Calmarius's user avatar
  • 661
2 votes
0 answers
73 views

Calculating spring constant c

Suppose we have 2 springs with different values for m and k. The first spring is given an arbitrary dampening value, ...
19172281's user avatar
  • 151
2 votes
0 answers
158 views

Approximate doom/heretic-style freelook distortion with modern graphics APIs

Currently working on a doom-like engine with fewer technical limitations, and looking into rendering techniques. I'm aware doom's a raycaster, and I want to capture a similar look but with modern ...
NotVeryMoe's user avatar
2 votes
0 answers
1k views

Idle game: calculating resource generation/consumption

I'm making an idle game in the vein of Melvor Idle and I've run into a problem calculating the yield and consumption of resources while the user is away. For those who don't know, many idle games have ...
RoboticWater's user avatar
2 votes
0 answers
243 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 ...
Chris's user avatar
  • 121
2 votes
0 answers
83 views

Compute spheres 2D speeds in perspective projected animations

I created two animations that consist of spheres moving in a perspective projected 3D space, which means that the size and speed of the spheres vary with the distance: they increase when they are ...
Kathia's user avatar
  • 121
2 votes
0 answers
113 views

Orthographic camera produces strange results

I've created a basic orthographic camera using the following view projection matrix: ...
Rick Nijhuis's user avatar
2 votes
0 answers
413 views

How do you find the collision between 3D boxes and 3D QUAD face meshes?

I have an axis aligned bounding boxes for 3D object collision, but I have a complex 3d mesh that's divided into 3d faces so I want to check for bounding boxes and collision with the faces of that ...
karamazovbros's user avatar
2 votes
0 answers
141 views

Handling a smooth movement over slopes in a worms like game

I currently have a worms like game with the worms style pixel perfect terrain destruction. Its working well for pushing things around and watching them fall, but for the players movement it feels like ...
Tyler H's user avatar
  • 121
2 votes
1 answer
316 views

Ledge Detection with Plane Intersection?

i am working on a ledge climb system and I am currently refactoring it to make it more reliable. I am tracing with a sphere towards infront of my character. If it found something, I trace downwards. ...
Raildex's user avatar
  • 741
2 votes
0 answers
129 views

Bullets moving with the camera, not the world, Java 2D

I'm building a simple 2D Top-Down shooter game in Java. I simply cannot get this to work: I'm moving the camera and world differently. The world is moving when needed (when not in one edge, so it ...
Kerdo's user avatar
  • 65
2 votes
0 answers
2k views

Euler angles to directional vector

I wanted to implement a directional light system in my game, and instead of passing the direction to the light, I chose to use an angle, and only later convert it to a directional vector, so it is a ...
Bálint's user avatar
  • 14.9k
2 votes
0 answers
80 views

Weird warping with per-vertex normals

I've had this little problem for a while now, where for some reason my calculations for per-vertex normals results in a weird distortion or warping, skewing my lighting, shading, and reflection passes....
Yattabyte's user avatar
  • 1,013
2 votes
0 answers
471 views

Hex axial coordinates to table coordinates conversion

I am developing a browser game based on a hex map. I am storing my data based on axial coordinates system. I developed a function which shows me axial coordinates of hexes within ...
Abdel5's user avatar
  • 173
2 votes
0 answers
440 views

How to calculate a quaternion rotation between 2 vectors with a specific final up vector?

I know you can calculate the quaternion rotation between 2 vectors with something like this after all the optimizations: ...
user68412's user avatar
2 votes
0 answers
48 views

get tetrahedron centroid velocity if vertex velocities known

If i have a tetrahedron and i know the velocities of the 4 vertices, how can I find the velocity of the Centroid? I know how to get the result if i know the velocity of the Centroid (i can use ...
user2901735's user avatar
2 votes
0 answers
186 views

Stereo 3D: drawing 2D elements at apparent screen depth

I'm developing an application making use of DirectX11's stereoscopic features. At such I am not relying on nVidia's automatic implementation. That means I have to replicate a way to render 2d elements ...
TheWanderer's user avatar
2 votes
0 answers
874 views

Quaternion to direction vector - flipping

I've kinda solved this myself by adapting the Camera::setDirection code from OGRE to work for my need: Now I have the following code: ...
Ilija Boshkov's user avatar
2 votes
1 answer
1k 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. ...
Karena D.'s user avatar
1 vote
0 answers
46 views

Trying to plot trajectory of rocket using only its current position and velocity components

I have a 2D controllable rocket for which I want to plot the parabolic motion. Additionally, the parabola should be able to change due to the thrust of the rocket accelerating it in either direction. ...
confused_aspirant's user avatar
1 vote
0 answers
58 views

Problems with RayCasting after fixing fisheye distortion

I am writing a pseudo-3D game in Python. After I tried to fix the fisheye problem, a new one appeared - if you stand close to the wall and look so that the wall is on the side, then the borders of the ...
kingley's user avatar
  • 11
1 vote
2 answers
147 views

In a 3D projection, how to find 'w' for every y point on the screen

I have a standard 3D rendering pipeline. Let's say I have a camera looking down at a flat plane that represents the floor. (in my game, z = height, so this is a plane where z == 0), and for ...
Tom Davies's user avatar
1 vote
0 answers
143 views

Attack/Defence formula: ensure defender wins a certain percentage of the time

I have two simple stats for my attack formula, attack and defence. I was reading through this answer which made it seem like ...
Josh Laird's user avatar
1 vote
0 answers
52 views

how to efficiently raytrace a rectangle side in 8bits without mul and div?

Imagine you are on a hardware that is 8bits like the nes or the game boy, NO mul no div, only add and shift. Given a rectangle or integer size nk*mk, where k is the size of the underlying grid, and P ...
user29244's user avatar
  • 327
1 vote
0 answers
94 views

Calculate 2d rotation to target (uniformly accelerated rotation, constant speed)

I'm trying to calculate an uniformly accelerated rotation for the autopilot module in my 3d space game shooter. The autopilot should fly the spaceship to any given point in the 3d space on the ...
user2850375's user avatar
1 vote
0 answers
743 views

Maths behind Unity rigidbody.AddForce

I've tried to understand the Maths behind AddForce, as to reproduce it using rigidbody.velocity +=. Based on the formulas ...
Ambroise Rabier's user avatar
1 vote
0 answers
123 views

How to implement texture slicing

I'm making a simple game in C# and i'm trying to slice my UI images into 9 smaller rectangles, so the image doesn't get stretched when drawing to different resolutions, but i'm having lots of problems ...
RickS.'s user avatar
  • 51
1 vote
0 answers
264 views

Why does the clip length of an animation not match my math?

I need to re-create an existing animation. The new animation should have the same amount of frames and length and FPS. Unity shows the following for the original / existing animation: As one can see, ...
tmighty's user avatar
  • 919
1 vote
0 answers
112 views

how can I normalize the speed of a polygon moving over a series of connected quadratic bezier curves with varying lengths?

I am generating a bunch of quadratic curves that are connected together, creating an array of curves, and a function which returns the position on the curve for a given time. ...
patrick's user avatar
  • 209
1 vote
0 answers
29 views

How can I draw a partial circle with LineRenderer?

I'm using the following code, which I found online, to draw a circle with a predefined radius centred on a predefined point in LineRenderer (2D game). ...
chpmerlin's user avatar
1 vote
0 answers
220 views

How can I calculate the inertia tensor of a hollow object defined by a triangle mesh?

I want to calculate the mass, center of mass, and inertia tensor of player created objects. Some of the objects will be hollow instead of solid. I am creating a closed triangle mesh for their object. ...
Sirius 5's user avatar
  • 139
1 vote
0 answers
42 views

Reinterpreting point inside a distorted cube

Given a cube: And a point anywhere inside that cube. Could that point be reinterpreted given any kind of deformation applied to the cube? I.e., where would that point be inside the deformed cube? ...
quano's user avatar
  • 111
1 vote
0 answers
84 views

Statemachine to behaviour tree?

Background I was able to convert simple statemachines like this... Into a BT looking like this (Notation describtion)... ...
genaray's user avatar
  • 517
1 vote
1 answer
181 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 ...
Josh M's user avatar
  • 11
1 vote
0 answers
28 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 ...
Mushington's user avatar
1 vote
0 answers
254 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),...
mbl's user avatar
  • 141

1
2 3 4 5