Questions tagged [mathematics]

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

1,554 questions
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 ...
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 ...
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) ...
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: ...
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.. ...
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 ...
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 ...
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....
99 views

...
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 -...
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 : ...
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 "...
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, ...
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 ...
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 ...
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 ...
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 (...
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 ...
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: ...
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, ...
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 ...
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 ...
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 ...
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'...
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:...
1k views

Is * calling *= (or *= calling *) slower than writing seperate functions (for math library)? [closed]

I have some vector classes where the arithmetic functions looks like this: ...
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 ...
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 ...
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 ...
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 ...
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....
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 ...
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 ...
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 ...
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: ...
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 ...
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 ...
153 views

Finding the Distance between 2 Objects

I have 2 objects One Having a Transformation Matrix T1 and other Having Transformation Matrix ...
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.
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 ...
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. ...
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 ...
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 ...
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-...
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 ...
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 ...
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....
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 ...