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)

1
vote
1answer
19 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
25 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
15 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
64 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
61 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
44 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 ...
1
vote
1answer
32 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
131 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
19 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
40 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
51 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
15 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
39 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
27 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
1answer
19 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
55 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
100 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
37 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
1answer
35 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
55 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
78 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
88 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
236 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
125 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
38 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
26 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
78 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
37 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
71 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
66 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
42 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
33 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
49 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 ...
0
votes
1answer
39 views

How to calculate normal vector of a curve?

How I can calculate the normal vector for tow dimension curve (I have the points of the curve in plane x y)?
6
votes
4answers
133 views

Evenly distributed checkpoints in a procedurally generated world?

Got a procedurally generated world. It's succinctly described as an undirected acyclic graph where vertices are junctions and edges weights/length note the amount of time/effort guesstimated to be ...
1
vote
0answers
12 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 ...
0
votes
0answers
20 views

Determine local “roll” from matrix

I'm allowing my player to maneuver freely in three dimensions. The world is very cubical, so it is useful to know internally (to help hint controls) which ground plane they're closest to paralleling. ...
9
votes
4answers
187 views

How do I correctly project a point behind the camera?

I am making a 3D game in which I put an exclamation marker above points of interest. In order to find out where in the 2D screen should I put my marker, I am manually projecting the 3D point where ...
0
votes
1answer
64 views

LibGDX make an object rotate around something

I need to rotate and object, which should be a circle made up with a ShaderRender, around a specified point. In LibGDX there is a method or something which allow me to do this? If it doesn't exist how ...
0
votes
0answers
30 views

Libgdx draw random wavy lines (similar to sinx)

I am looking for drawing a wavy road. It must be random and I have to add an hitbox on its bound, how can I do it? I want drawing red objects Example :
0
votes
0answers
15 views

Screen coordinates to letterboxed view

So I have letter boxing working properly (it's not really important but I'll post that bit of code too), but I'm trying to figure out the point/vector arithmetic for translating (projecting) screen ...
0
votes
1answer
36 views

How to make a joystick follow the touch around a starting point using atan2?

I would like to move a joystick, and be able to go beyond the limit of the circle, and the joystick should follow the angle from the touch (the touch is moving), but it should stay on the circle. It ...
0
votes
1answer
45 views

Given a constant rotation and target point, find position so that point will be in camera center

Given a fixed rotation and a target "center" point, how to I find the position the camera should be in so that that point is the center? LookAt changes the rotation keeping the position constant. ...
0
votes
3answers
63 views

Non equi-probable random function

I was trying to find or make a function which is not equi-probable, meaning some values are less probable than others. Apparently what I want has something to deal with ...
1
vote
0answers
72 views

Transformed Vertices have wrong Z Axis

For quite some time I've been working on my open 3D game engine, to learn how this stuff works. You can see the full codebase relating to my problem here on GitHub. I'm using an OpenGL 3.3 Core ...
0
votes
0answers
51 views

Libgdx trying to get reflection of ball with plane in 3D space

I just cannot seem to get the right reflection result. Have tried reordering the operations but none seem to work. Hoping someone might tell me what I am doing wrong. Trying to accomplish the formula ...
-1
votes
1answer
93 views

Cannot find bug in frustum culling code

I've written some code for frustum culling, but for some reason, it is not working, and i can't find the bug in it... Maybe a bug in the math, somewhere? So, i'm asking you if anyone could check these ...
1
vote
2answers
105 views

Circle-Circle collision resolution

This seems easy but I can't figure it out, when I have one circle(c1) collide with another(c2) I give the c2 circle the heading of c1 and send the c1 circle on the normal vector to the heading (the ...
1
vote
1answer
186 views

Quaternion Slerp and Lerp implementation (with overshoot)

I am working with Unity (C#) and was looking for an implementation of Slerp and possibly Lerp that allow overshoot (progress not strictly limited to 0..1 range). I want to do some tweening animation ...