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.

0
votes
1answer
69 views

Predict Time of projectile flight

I am trying to matemathically predict how long will projectile fly until it reach the target. I am trying to implement this formula: t = [V * sin(α) + √(V * sin(α))² + 2 * g * h)] / g where I know ...
0
votes
0answers
11 views

How to implement Meshlab's rotation manipulator? [duplicate]

I want to implement a rotation handle/manipulator mechanism that would enable user to rotate a 3D model exactly like Meshlab does. Unfortunately I don't fully understand how does the rotation gizmo ...
0
votes
0answers
29 views

The X axis becomes the Y axis after a quaternion rotation

I am making a FPS game, and I have a for loop where I place out "ground" objects. (pseudo code) ...
22
votes
4answers
8k views

Bezier curve arc length

See also: same question on Math.SE How can I find the arclength of a Bezier curve? For example, a linear Bezier curve has the length: ...
1
vote
2answers
79 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.. ...
1
vote
1answer
51 views

rotation matrix problems - opengl and own types

In an effort to learn things deeper I'm writing my own mathematics for the first time instead of using libraries. As far as I can tell my matrix multiplication is correct, and translation and scaling ...
2
votes
3answers
151 views

Get closest point on box to line

Eventually this problem will be 3D, so I would like a solution that works in 3D. My player is looking forwards. There is an axis-aligned box on the screen (FOV is guaranteed to be 90, so boxes behind ...
0
votes
0answers
19 views

libGDX - Zooming on a specific point in 2D space

I was hoping to modify my game so zooming would focus on a point: the mouse location on desktop or the midpoint between two fingers on mobile. This appears to require a simultaneous zoom and translate....
0
votes
1answer
36 views

Capsule to Sphere Collision

For my Maths unit at university, we have to manually calculate if a sphere is colliding with a capsule collider. The information I have to go with is this; You have the following Sphere: LadyBird3 -...
0
votes
1answer
107 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 : ...
0
votes
0answers
27 views

Yaw on a spherical world

I am trying to make a game where the player can walk along the surface of a spherical planet, and am not sure how to handle orientation. Pitch is relatively easy, as it is simply how much "above" or "...
0
votes
0answers
27 views

How to move an object in a heart shape pattern in javascript?

How can I move an object in a heart shaped pattern? I have a move(x, y) function that I can use to move the object, but how to I make a function that will move the object in a heart shaped pattern, ...
12
votes
4answers
23k views

How to detect 2D line on line collision?

I'm a flash actionscript game developer who is a bit backward with mathematics, though I find physics both interesting and cool. For reference this is a similar game to the one I'm making: Untangled ...
0
votes
1answer
69 views

How to compute the moves amount in a match-3 game?

I have a match-3 mobile game, similar to these popular games in the store. Mechanics are different, but the gameplay stays the same: NxN board X moves Y objectives to complete to win tons of ...
0
votes
0answers
56 views

Quaternion Rotation after performing previous rotations

Have Quaternion \$ Q\$ which is rotated on the \$X\$ axis 90 degrees. \$Q\$ is now \$ (0.707106, 0.707106, 0, 0)\$. I want to rotate \$Q\$ another ...
0
votes
0answers
21 views

Divide screen in eight sectors [duplicate]

Currently in our game we use a 4 directional movement. Some abilities are triggered on mouse click and "fired" in the direction the player has clicked. For this, I have split the screen in 4 sectors (...
0
votes
0answers
16 views

Moving and rotating object with another object [duplicate]

Sorry i bad painter)) Need move and rotate 'OBJECT №2' with 'OBJECT №1' I have origin point(also rotation point) and angles of two object. (Also min and max coordinates of these objects) Vector ...
0
votes
2answers
88 views

A* GetNearest() implementation

I'm trying to implement pathfinding in my platformer and I'm having trouble coming up with a way to find the nearest node to a world point. I tried this: ...
1
vote
1answer
40 views

An algorithm to make one object follow another on a 2D grid

I am using Greenfoot, but this can apply to pretty much any 2D engine. So my question is a basic one that I somehow couldn't find an answer to already. Basically, if I have an enemy and the player, ...
0
votes
2answers
42 views

How to implement this XP formula?

I found this response but the thread is closed: https://gamedev.stackexchange.com/a/13639 level = constant * sqrt(XP) I seem unable to properly get current level, this is how I tried to do it, and ...
0
votes
1answer
36 views

Movement velocity relative to a static object (Vector Maths)

I have a static object. I have a moving player. If the player is moving directly towards the object then I want to return the value of 1. If the player is moving directly away from the the object ...
1
vote
1answer
642 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 ...
0
votes
1answer
40 views

Algorithm for finding edge vertex points on a tilemap

I have a 2d tilemap array contains 1 or 0. 0 corresponds empty tile, 1 corresponds solid tile. If tile is 1 I draw a texture. I have to find edge vertices and coordinates that 1's grouped. I couldn'...
0
votes
1answer
28 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:...
15
votes
1answer
1k views
0
votes
1answer
105 views

Acceleration in Unity

I am trying to emulate acceleration and deceleration in Unity. I have written to code to generate a track in Unity and place an object at a specific location on the track based on time. The result ...
3
votes
2answers
262 views

Shrink a convex polygon

Shrinking a concave polygon is quite hard, to do well. But I expect shrinking a convex polygon would be easy. The naive approach of moving each vertex a certain distance to the centre gives me poor ...
0
votes
1answer
19 views

Moving object with preset timelapse

I am a newbie game developer. I have one problem. Consider the following case. I have a simple game with only one object - a ball. A ball can move only up and down from one side to another. A User ...
4
votes
3answers
441 views

How to use Moving Average to avoid lucky streaks in RNG

I spent the last week reading about Luck Mitigation and what a dev can do to avoid extreme cases where the player's psychology will be messed up. I came up to this question How do I avoid “too” lucky ...
0
votes
0answers
27 views

Rotate a Vector by Quaternions

I'm trying how to work out how to Rotate a Vertex using Quaternions, using a scientific calculator, or on paper. Exam preparation. My lecturer has given us this; Quaternion = (-0.5, 0, -0.7071067, 0....
0
votes
1answer
167 views

Offset on camera following object that accelerates

I have camera a that is actively following an object (a plane) from behind. This object can accelerate or decelerate. I would like to have a camera offset when I move the plane, so it doesn't look so ...
0
votes
1answer
171 views

Calculating real time moment of inertia around arbitrary axis in 3d

I have a 3d rigid body consisting of multiple triangles forming a closed mesh. I know how to calculate the moment of inertia around an arbitrary axis by splitting up the mesh into simpler shapes and ...
2
votes
1answer
46 views

How would I rotate my billboards parallel to the camera view?

I'm trying to make my own space-sim in Godot and I'm stuck trying to get the visuals of the "starfield"-effect that is a staple of the genre. I'm using a Particle system with billboards that would be ...
0
votes
1answer
173 views

Rendering an isometric tilemap

I have a tile which is 512x256 pixels and I'm trying to render it in an isometric fashion. I have this helper function: ...
1
vote
2answers
442 views

How to get the point of collision in Separating Axis Theorem?

I'm interested in the relatively precise point (not line) of collision for calculating angular velocity on impact for use in a impulse calculation. At first I thought, perhaps naively, that I could ...
0
votes
1answer
92 views

Top down off-screen indicator, Unity3D C#

I'm working on a top-down 3D game where things spawn off camera. Movement only occurs on 2 axis (x and z). Rotation is about y axis. The player is in the center of the camera and needs to have ...
0
votes
2answers
153 views

Finding the Distance between 2 Objects

I have 2 objects One Having a Transformation Matrix T1 and other Having Transformation Matrix ...
-5
votes
3answers
2k views

How can I find a point on a line when I have only two other points?

I have a straight line passing from points A(2,-1) and B(4,5). I want to find a point C that is on the line and outside A-B.
1
vote
2answers
377 views

Find vector tangent to circle through a point

C2 and P1 are known points. Radius of circle C2 is also constant and known. I am trying to find point T to eventually construct line p1-t, which is tangent to circle c2. I have made an attempt ...
0
votes
1answer
23 views

How can spotlights be implemented with a perspective projection?

I was reading Shadow Mapping with Directional Lights and noted that spotlights are implemented by rendering with the perspective projection, stating that the spotlight worked just like the camera. ...
0
votes
1answer
47 views

2D vehicle collision detection and rotation

I'm attempting to make a simple 2D car game from scratch, but I can't figure out the collision detection between a vehicle and a road. The vehicle should also rotate appropriately to its position on ...
0
votes
1answer
51 views

Third Person SpaceShip Camera Directx9 follows objekt but gets weird after moving object

We have the following code. It should follow the game Object in every step but it does not. In the beginning we can rotate the object where ever we want and it works but after moving it some the ...
2
votes
1answer
70 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
40 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 ...
1
vote
1answer
599 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 ...
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....
11
votes
4answers
20k views

GLM: Euler Angles to Quaternion

I hope you know GL Mathematics (GLM) because I've got a problem, I can not break: I have a set of Euler Angles and I need to perform smooth interpolation between them. The best way is converting them ...
1
vote
2answers
5k views

GLM: Quaternion SLERP Interpolation

I wish to interpolate two quaternion values. As I still can not get working results, can I kindly ask you to verify my function calls? The code below supports GLM (OpenGL Mathemathics) library, so ...
2
votes
2answers
407 views

Understanding constant acceleration in terms of game physics simulation

There are various integration methods that can be used for games. I am trying to write a simple physics engine deciding between semi-implicit Euler and Verlet variants. What I don't understand is ...