Mathematics questions deal with the arithmetic, geometry, calculus, formulae and other calculations used in the development of a game.
0
votes
1answer
8 views
Problem calculating screen point for a point in a 3D world with view matrix and projection matrix
I am trying to calculate the 2D screen point of a 3D world position. For this I use the multiplication ViewMatrix * ProjectionMatrix. But I am not getting good results and I think I am messing up my ...
2
votes
1answer
30 views
Issues with OpenGL rotation matricies and shaders
I am having an issue with my rotations in my opengl shaders. My program works fine before I add in my rotation matrices. Here is an example, at YouTube. After I add rotations to my shaders, there are ...
0
votes
1answer
24 views
Can't understand why transformation doesn't work
To make a simple transformation like a rotation I want to use linear algebra -multiplying the vec4 vertex_position by a mat4 transformation
If alpha is the angle of rotation, then the mat4 is ...
0
votes
1answer
26 views
Java/Libgdx - Finding distances between sprites in an array
i'm new to java and was hoping if anyone can help me out. So my game has meteors which spawns off screen and sometimes as they spawn, they overlap each other which I don't want. I want them to spawn ...
0
votes
2answers
106 views
How does one calculate the surface normal, in 2D collisions?
I have a ball, which should bounce when it collides with a surface. I know the formula for reflections;
(v1 - 2(v1 • n)n)
However, I cannot obtain the required information. I know:
the ball ...
0
votes
1answer
33 views
What's the difference between setTransformMatrix and setProjectionMatrix in LibGDX?
There are two method of SpriteBatch in LibGDX: setTransformMatrxi and setProjectionMatrix.
I know one can use batch.setProjectionMatrix(camera.combined) to define how/where an object should be ...
0
votes
1answer
46 views
Inverse Kinematics using Pseudoinverse Jacobian
I'm having problems solving IK with Jacobian Pseudoinverse method.
What I do is:
At each local joint frame q_i of the chain q calculate the cross product between rotation axis (taken from local ...
4
votes
0answers
37 views
How to clip cut-off using different frustrum than that of original camera? How to cut plane by pyramid shape?
SOURCE : http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Mitchell_LightShafts.pdf
This process is part of creating light draft effect. And I am suggested to do the described process in ...
0
votes
0answers
39 views
Calculating voronoi sites with a 2D grid
I've been diving deeper into voronoi cells for use in a 2D game. There's a lot out there that explains the concept and describes how to calculate them but I'm failing to grasp how best to apply them ...
0
votes
0answers
24 views
Get face translation/rotation/scaling from 2d face
I have a 2d face stored in a vbo. This face is along xy axis.
Then I have a cube that I have to render with using this face. The cube is defined by firstPosition and secondPosition. In some way (I ...
0
votes
0answers
45 views
Any examples on how to set up damage deal on country simulation(population decrease)?
maybe the title is a bit lacking... I did find a lot of data about how damage is done in RPGs but not in strategy simulations.
I wanted to figure how population increase/decrease by it's ratio in ...
0
votes
1answer
22 views
Three points to normal notation (interpret the math)
From: Euclidian Space: Planes, I see the formula:
Convert Three points to normal notation
N = (p1-p0) × (p2 - p0)
d = -N • p0^2
where:
N = normal to plane (not necessarily unit ...
0
votes
1answer
29 views
Coordinates of the corners of a rectangle bridging two circles
I am implementing a game that involves slingshots and circular objects. I have gotten the basic "geometric" construction down for rendering the slingshot, but I am having trouble implementing this in ...
0
votes
1answer
40 views
Box2D in 3D space
I am trying to combine a perspective camera with a box2D world using libgdx and I am having some problems getting the two to synch up. I want to do this so I can use 3D models but keep the game in a ...
0
votes
1answer
39 views
Converting back and forth between spherical and cartesian coordinates in glsl
I have checked all the possible resources and I still don't know why my code is not working.
This code should convert uv (texture coordinates) or cartesian into spherical and back. But my code still ...
-2
votes
1answer
34 views
Increase event trigger chance the closer two numbers are
I have two numbers, one steadily increasing, the other is fixed. I'm trying to increase the likelihood of triggering an event as the increasing number gets closer to and surpasses the fixed number.
...
0
votes
0answers
31 views
Simplifying probabilities when scoring in one on one situations
I'm trying to simplify the scoring of a win/loss simulation. The situation is as follows:
Let's say there are two players A and B where:
When A goes into a battle, it's probability of a win is 0.1 (...
1
vote
1answer
95 views
Difference in definitions of “Minkowski difference”
I'm trying to understand Minkwoski difference, as it relates to collision detection.
It seems, to me, that there are two definitions of Minkowski difference floating around. One, as defined by ...
0
votes
3answers
58 views
Collision Detection works 2 sides - Minkowski Sum xna
This might be really simple but it is giving me a lot grief and I wondered if you guys would be able to shed some light on it. Basically I have a tile map which draws tiles at 64 * 64 and that works ...
6
votes
2answers
210 views
How can I randomly generate objects inside of a Complex Area?
In my game, I want to generate randomize enemies inside of this green area that I made with a custom editor tool.
0
votes
1answer
103 views
How do I convert distance covered from meters to kilometers, in Unity?
I am developing a game in Unity where I have to find a distance in kilometers, to find a passenger's fare based on the covered distance.
This is what I have tried:
private Vector3 previousPosition; ...
0
votes
1answer
33 views
Date Time math (A little Detail Missing)
Ok, so I have this public void, where I'm trying to subtract one date from the other, and then divide it by an integer number:
public void BonoDatos () {
//public InputField StartTimeBono;
//...
-1
votes
0answers
41 views
Extracting the view frustum planes
I am attempting to extract the view frustum planes so that i can accomplish clipping and culling yet i am failing to get the correct planes and i am not entirely sure why, i will attach the code for ...
1
vote
2answers
104 views
How to calculate building cost with production per hour?
I know that it may not detailed thread title but I will give more detail about my question.
I'm working on a strategy game, and can't find a solution about building cost or training cost. I spent 1 ...
0
votes
2answers
69 views
Determining which point is further along a direction vector
I am attempting to write a frustum culling algorithm simply by testing axis aligned boxes against a plane, while researching this i came across an article here:
enter link description here
The trouble ...
0
votes
1answer
54 views
Difference between column- and row vector matrix multiplication (vector transform)
Let's say we have a 4-by-4 matrix A which represents some transformation.
We can use this matrix to transform a vector in two ways.
Ax by assuming x is a 4-by-1 column vector.
xA by assuming x is a ...
0
votes
2answers
24 views
How to work out the height of a point on a tilted surface?
I have a plane which gets tilted on the X and Z axis (y+ is the normal).
Given an X and Z coordinate and the X and Z rotation of the plane, how do I find out the height (Y) at that point?
I assume ...
0
votes
2answers
127 views
Calculate current level and level requirements when only XP is being updated
I am trying to create a formula to calculate the players level based on his XP alone. The game currently only increments his XP after certain actions.
I have the formula for calculating the required ...
2
votes
2answers
57 views
Merge angle range
I have AngleRange class with define range to angles to detect if a angle is inside the range.
public class AngleRange
{
private readonly double _from;
private readonly double _to;
public ...
1
vote
0answers
38 views
Decide which scoring system to use and number of points to assign for new game [closed]
I am developing a new game and would like to know if anyone could point me in the right direction for deciding the type of scoring system to use for my new game as well as the number of points to ...
0
votes
2answers
28 views
Calculate line intersecting most points, based on random points in a grid
I have been struggling with a math issue for a game I've been developing. I am in need to find the best starting and ending point for a straight line so that it intersects most of the circles (the ...
1
vote
1answer
40 views
Drawing & transforming matrices upwards
I'm drawing a hierarchy of 3D objects in C# XNA where each objects has a transform that holds position, rotation and scale.
I get my expected results If I draw my objects from my root node in this ...
0
votes
0answers
28 views
Approximating a fourth point with a weighted average between three points?
Given three points, how would one approximate the best positive weights (u, v, w) such that u+v+w = 1, and that the distance between the new u*p0 + v*p1 + w*p2 from p3 is minimal?
Basically, the ...
0
votes
1answer
29 views
Transform point while keeping other points offset
I have the following situation: I've got a box with its center of mass transform matrix that I'm obtaining from physics simulation, i.e. it keeps changing with time. I've also got two points (actually ...
1
vote
0answers
154 views
3D software-based engine projection issues
i have been writing a 3D soft-engine for a little while and i have gotten it a reasonable position but recently noticed a bug that i can't seem to solve. When i am rendering a few cubes as a test, if ...
0
votes
2answers
20 views
Timebased transition from start to end value
I'm trying to implement time line objects, the purpose of those would be to issue events at specific times. When and what is specified through objects called units, which is what you attach in the ...
0
votes
1answer
57 views
Hemisphere Projection
I came across the following segment of code that is supposed to project an image on a hemisphere:
void main(void)
{
vColor = aColor;
vec4 pos = uModelViewMatrix * vertex;
float lenxy = ...
0
votes
3answers
91 views
Calculate damage values from bullet velocity and size
I'm trying to make a top-down game using javascript and Pixi which involves multiple different guns.
Instead of giving each gun an individual damage value, I wanted to calculate the damage by the ...
0
votes
2answers
93 views
Determine the z coordinate of a deformed plane based on uv (xy) coordinates
I am using a formula to turn the following texture
into what looks like two 3 dimensional planes
The formula I am using for the texture deformation is
float2 texUV = float2(uv.x / abs(uv.y), (1.0 / ...
-1
votes
1answer
50 views
Perlin Noise' gradient
I'm having some problem understanding the Perlin Noise algorithm and none of the explanation I found go into this (probably obvious)detail.
From what function is the gradient on it? Is it from the ...
-5
votes
1answer
124 views
Why aren't there game and physics engines with double precision?
Choice of game design and other human psychological factors aside
is the present hardware not capable of working with double precision floating point calculations with reasonable performance? It can ...
1
vote
1answer
41 views
How to handle edge cases for a cell divided multiplayer world?
The most common practice that I read about for overcoming floating point precision in video games with large worlds is by dividing the world into cells and load it with player's position and shift ...
6
votes
1answer
142 views
render text inside countries
I have a map of the world and I want to place text on top of each country. The text can be anywhere from 0 to 1000 symbols long, and can often be changed.
I'm looking for an algorithm to layout text ...
1
vote
1answer
79 views
LIBGDX Perspective Camera in an Isometric view?
how can I set a PerspectiveCamera to view the game in an isometric view? What kind of angle would I use, and how would I actually translate this into the code? Math isn't my forte, so I can't really ...
0
votes
1answer
40 views
Axis of affine transformation matrix
Lets say I have a right handed column major 4x4 transformation matrix. Can I safely assume (even tough there exist non uniform scale) that first column is X axis vector, second cloumn is Y axis vector ...
1
vote
1answer
39 views
Project 3d lines onto plane
I'm trying to wrap my head around coordinate projection, and can't seem to solve the problem I am having. Here is an illustration of it:
The cubes represent 3d space, and the 2 red lines represent ...
2
votes
1answer
62 views
Find the closest point on a ray
I've got a ray defined by P1 and P2, and then a target P3, and I want to find P4. How do I go about this? I've come to understand that I should use vector projection, but I can't get it to work. Any ...
0
votes
2answers
88 views
Finding the Distance between 2 Objects
I have 2 objects One Having a Transformation Matrix T1 and other Having Transformation Matrix T2. And We are having a View Matrix V and Projection Matrix P.
Basically 2 Object are render using this ...
0
votes
0answers
21 views
FInding out if a shape is enclosed by other shapes
I'm trying to programmatically work out if a 'core' shape is surrounded with other shapes and thus no space exists around it. Here's an illustration of what I mean (ignore white gaps, they are just to ...
1
vote
1answer
101 views
Finding if 2 polygons intersect using clipper library
After realising my code was pretty inefficient at checking for polygon overlaps, I've turned to a mentioned library Clipper but finding it difficult to know hot to use it for this operation.
I am ...