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

learn more… | top users | synonyms (1)

0
votes
0answers
28 views

Can anyone recommend a 24.8 or 32.32 fixed point library for java? [on hold]

As the title says - I can't seem to find any working implementations. I need it for a cross platform game where I need floating point calcs to be deterministic. I can't use strictfp etc. Thanks
5
votes
1answer
68 views

How do I go from world coordinates (X/Y) to tile coordinates?

So, I've got this game rendered in fake isometric view with the following code for generating the mesh: _x = x + ( y & 1 > 0 ? 0 : 0.5 ); _y = y * 0.25; ADD_VERTICES( [ _x-0.5, _y, ...
0
votes
0answers
37 views

How to get a difference of angles in one mathematical expression? [duplicate]

I need to do this for AI and also range calculation over a curved surface. I have two angles, a1 and a2, which can be in the range from 0 to 359. I need to calculate the difference between them, and ...
0
votes
1answer
18 views

Move an enemy towards the player in pygame

I set variables for the distance between the enemy and the player along the x-axis and y-axis. My plan is to move the enemy along the hypotenuse formed by y and x-axis line at a constant speed. The ...
0
votes
0answers
18 views

.NET Geometry Library [closed]

Is anyone aware of a .NET library that implements just the geometry functions of a typical 2D game? Something that isn't bogged down with graphics, but just the basic math models and functions? Such ...
0
votes
1answer
22 views

add the variation of the angle to its current angle: trouble with 180 and -180

I need to rotate a character, I would like to add the variation of the angle to its current angle. But my values are between 180 and -180. So if my character is at -179, then he goes right, it arrives ...
0
votes
1answer
31 views

I want to design a scoring system calculating coins, stars and lives, (50%/ 30% / 20% ) [on hold]

the player has to collect coins to clear levels. he has to collect stars to unlock collectibles. collection of coins lead to purchase of lives. Hence the importance to lives. (50, 30, 20)
2
votes
0answers
73 views

Path following with Asteroids-like movement. Time to complete path

I'm currently learning about how to do this, but it's best to post the problem beforehand. (posting on Physics and GameDev, as you guys know your math) It's quite difficult to explain. This specific ...
1
vote
1answer
83 views

Calculate the slope of a 3D triangle?

I have lots of triangles in 3D space. How do I determine the slope/angle of these triangles with respect to a fixed ground plane? I need pseudo code examples at the very least. Thanks! [edit] Based ...
4
votes
1answer
217 views

How To Program a fully controllable spring (Damped) motion

i'm working on a project that needs realistic 2D Animation, none linear motion you might say, i have tried many things such as Hermite Curve and a few other motions and in the end Spring Motion. ...
0
votes
1answer
27 views

How can I create a parabola that does not use negative X coordinates

I am currently devloping my first javascript program ever which is a table tennis game. I am trying to create trajectory for the ball to follow when hit - just a very basic parabola. However im not ...
0
votes
0answers
34 views

Gravity and Jumping in Clickteam Fusion 2.5

So I'm currently building a bare-bones functioning game that involves simple platforming. Quite literally a box moving left and right and jumping. I'm using Clickteam Fusion 2.5, and I know there's an ...
1
vote
1answer
35 views

To find a success list in group

I try to find a success list among players for my project. I thought If I find the winning probability of players , it would give me the success list in group. I would like to give an example to ...
3
votes
1answer
99 views

Calculation correct position of object after collision (2d)

I have a circle, that bounces of walls. The circle is traveling at the speed defined by px/s for x and y. I have collision detection implemented and I use vectors to calculate the new x/y speed (and ...
2
votes
0answers
37 views

Arma 3 - How to calculate height of a thought line over a known spot in 3rd person view?

Assuming a player object with third-person-view is in a 3d room and the center of the screen has a dot - let's call it "cursorTarget". All I have is the position of the player, the position 5 meters ...
1
vote
1answer
75 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 ...
1
vote
1answer
42 views

Move a sprite in a sine wave along different angles

I understand this piece of code Enemy.position.Y = StartPosition.Y + (-(float)Math.Cos(position.X / 100) * 100); However it only works along the X axis. What I want to be able to do is move it along ...
1
vote
0answers
26 views

Interpolate camera rotation over many keyframes smoothly

I have a defined set of rotation/position keyframes that I want a camera to animate between smoothly. Handling the position is easy enough using cubic bezier curves (and just auto-generating the ...
0
votes
0answers
17 views

How do I generated cubic UV coordinates for a mesh?

I'm trying to add a utility function to my game engine that generates cubic texture coordinates for a specified mesh. I've attempted to come up with my own algorithm but I can't get it to work ...
2
votes
1answer
80 views

How does matrix based game physics (collision detection & response) work?

I'm familiar with how to do collision detection and response using shape intersection tests, the separating axis theorem, and by using MPR and GJK with minkowski sums and support vector defined ...
-2
votes
2answers
66 views

What's the difference between the representation of a line and that of a line segment?

What is the difference between a line and a line segment from the implementation point of view? To me, line segment means: class LineSegment2d { Point2d start, end; public: ...... } This ...
0
votes
3answers
46 views

How to find the point on a hypotenuse divinging triangle into two right triangles?

Consider the following image: Knowing the (x,y) coordinates of A, B, and C; how would one find the point D? D being the point where line CD cuts the triangle into two smaller right triangles? I ...
2
votes
1answer
50 views

Curvilinear distortion for mapping texture on quad sphere

I'm using the formula I've found here to map procedural texture on to a quad sphere. For example I'm working with a 3d panoramic cube map that I've generated with a simplex noise. Each face of the ...
2
votes
5answers
157 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
2answers
38 views

Calculating pitch angle to hit a target using a projectile that has fixed speed

I am trying to calculate a vertical angle needed to hit a target at [distance, elevation] 2D coordinates relative to shooter given a fixed projectile velocity, air drag and gravitational ...
2
votes
1answer
44 views

How to calculate if a point is contained in rectangular camera viewport with rotation?

I am working with my camera, and am trying to improve it so that I can calculate if a world point is on screen, taking rotation into account. Currently, my camera rectangle is calculated as so: ...
0
votes
0answers
32 views

3D Picking: Doesn't Work Consistently

I'm trying to implement a 3D picking function that at the moment simply calculates the ray being sent from the camera after the user clicks the mouse on the window. It kind of works well when the ...
3
votes
1answer
52 views

Finding coordinate in radius

Hello i have two points (Vector3) A and B. And have a radius r How can i find a coords of point P in a circle by angle?
0
votes
0answers
21 views

Cube map for texturing edge distortions

I am using a cube map to texture a sphere and all is well except the seams that become very noticeable near the corners of the cube. I have tried to correct the sampling coordinates in the shader, ...
1
vote
0answers
48 views

Calculating orbital elements from Cartesian Vectors

I'm having serious troubles with getting my calculations to work. I'm calculating the orbital elements from a position vector, and a velocity vector. (I also know the distance and mass of the bodies ...
1
vote
0answers
34 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: quat quat::fromtwovectors(vec3 u, vec3 v) { vec3 w = cross(u, v); ...
0
votes
2answers
40 views

Rotate coordinates back after rotating game context (geometry)

To achieve something similar to the image below using HTML5 canvas one can simply write the following: var TO_RADIANS = 0.0174532925; context.translate(30, 20); context.rotate(30 * TO_RADIANS); ...
0
votes
1answer
62 views

How does collisions caculates when developing game in Build an HTML5 Game book

I don't understand authors login when calculating collisions between two circles (bubbles). Here is the Calculating collisions section. Author writes: The bubble being fired follows a set of ...
0
votes
1answer
118 views

How to generate interresting procedural terrain [closed]

I work on a voxel-like game, and I have finally managed to create some basic terrain generation using simplex noise. Heres what it looks like: Sure I can generate different kind of terrains (more or ...
1
vote
0answers
38 views

Portal view direction

I'm trying to add portals to a game (as in the entities from the Portal video game), and I've gotten them to a render the other portal's pos/dir to a texture which I can then display on a surface. ...
0
votes
2answers
48 views

Generating hidden box collider between two game objects in unity

I'm trying to implement flappy bird clone using unity. I'm creating two obstacles at random y position. I would like to create a hidden box collider game object between them, but I'm struggling with ...
2
votes
1answer
56 views

Transition between normal and slow motion

I have a game (C++) in which I want to transition between two speeds of motion. For illustration, the player raises their weapon to aim, and whilst this is in progress over a known duration, time ...
2
votes
1answer
82 views

Determine if AI can traverse a given spline

I have some AI Agents that I want to navigate along a spline. The agents have a speed and a maximum turning radius. For some splines the curvature is too tight for the AI agents to navigate around and ...
3
votes
1answer
91 views

Is it really necessary to test collisions against triangle vertices and edges?

I'm reading this paper, and using it to perfect the narrow phase collision system for my game engine. To make the question as self-contained as possible, the essential strategy used to detect ...
1
vote
2answers
257 views

How can I calculate the future position of my moving object?

I'm relatively new to games development and I have a 2D game where the playing area is an enclosed rectangle with width w and infinite height. In the playing area there is a ball. A gravity force of ...
4
votes
1answer
161 views

Convert large range of numbers to a smaller scale

What is a good formula to use in order to relate two different scale distances to each other? For example, I have a camera that can have a minimum size of 2 and a maximum of 10. I would like the ...
-1
votes
1answer
43 views

Perspective projection? [closed]

I am trying to write an elite like game and I kind of understand the maths behind it but it would be really helpful if someone could explain it.
0
votes
1answer
27 views

Getting curved-based zooming speed?

I am able to get a fairly smooth zooming function going on in my project. However I'm hoping to achieve a non-linear function. I've tried using the smoothstep function but it doesn't feel smooth ...
4
votes
1answer
79 views

Cram search results into viewport (of a search minimap)?

I'm no coder, nor do I try to be. I just had one of those "it's impossible" arguments with folks who love to argue with me before they even understand what the argument is about :) So I need to ...
1
vote
1answer
39 views

Rotate an objects velocity

I have a collision system (in 3D but for the purpose of the question assume 2D) where I want to calculate the new velocity (stored as a vector) after a collision. What I have is the velocity of the ...
2
votes
3answers
74 views

Get algorithm (Chance-to-Hit) from Input and Output

I am currently working on a chance-to-hit formula for an rpg. It consists of the following parts: AttackSkill: The used Attribute of the Attacker (Range: 1-10) AttackBonus: A Modifier from ...
0
votes
2answers
76 views

Move towards view direction opengl?

I'm trying to get the basics of 3d with opengl 2.0(I know, I know, it's deprecated etc, etc. It's just for the sake of prototyping). I'm trying to get a cube on the screen which you can move around. I ...
1
vote
1answer
44 views

Computing Normals for a displaced material

Disclosure: cross-posted on Unreal Answers, thought was sufficiently general for GameDev.SE I am currently rendering a displacement texture and, separately, a normal texture for my ocean. Is there a ...
1
vote
1answer
44 views

How to move sprite mimicking mouse/touch position on some part of the screen?

I am having a difficulty and I am been doing it wrong, I think. I want to move sprite relatively to touch. Just like when you are playing space shooter like 1943. I just learning some math and try to ...
0
votes
1answer
54 views

Controlling the movement of player by sprite using Mouse

I want to move the player by pressing down on the mouse and moving around by dragging. The player won't move to the position of the mouse. Instead it should be relative to the players current ...