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
2answers
59 views

Help with a formula; The bigger the number, the smaller the result

Math has never been my strong suit and so I'm having trouble figuring out how to write this formula. When you buy something in my game, the amount it costs to purchase that item will be taken off ...
0
votes
0answers
55 views

how to generate human face mesh with array of vertices [closed]

I want to generate mesh for human face for android app using opengles2.0 from the array with vertex points which lies on boundary of the face,for example float[]Array={0.05f,0.4f,0.0f,0.3f,-0.8f,0.0f,....
0
votes
0answers
28 views

Convert AABB to SAT help

I have recently implemented Axis-Aligned Bounding Box collision which works really well using the Minowski sum psuedocode which get which side of the rectangle is hit by the player (also a rectangle). ...
0
votes
1answer
38 views

Calculating angle to aim at target results in over/under aim depending on whether target is below/above

I'm calculating the angle (in radians, ranges -3.141 to 3.141 for yaw and -1.343 to 1.396 for pitch) to aim at in order to aim at a target position. The data I have is my local world camera position, ...
0
votes
0answers
29 views

Math question. Determining a Keplerian Orbit value after changing the orbit

I have a working Keplerian orbit simulator, as long as I don't change any of the orbital values at runtime it all works fine. However, I am trying to add thrust while the simulation is running. Right ...
3
votes
1answer
104 views

How can I move and rotate an object in an “infinity” or “figure 8” trajectory?

I know that the easiest way to move an object with the figure 8 trajectory is: x = cos(t); y = sin(2*t) / 2; but I just don't know how to rotate it, lets says with a new variable r as rotation, how ...
1
vote
0answers
40 views

Issue calculating new angle for player to look at some 3d world object

I am working on a Unity game where the Euler angles of the player display some weird behaviour that I cannot understand. There seem to be two full 360 degrees rotations, one positive and one negative. ...
0
votes
1answer
27 views

Given a point on the surface of an OBB, return normal of the face

So I have this class OBB which implements a test function that determines whether a ray hits it. If it does, a passed in struct is assigned a bunch of variables: struct HitData { float t; ...
1
vote
2answers
66 views

Find X,Y Spiral positions by given ID. Hard formula.

I need to spawn new villages in my grid-based game map. But i am weak in advanced math.. I need to fetch coordinates by id. These 2 constants can be other numbers. Please help with the function in ...
1
vote
1answer
52 views

Simple 2D vehicle physics - maintaining vehicle length

I'm learning OpenGL and trying to make a simple simulation, which involves vehicles (drawn just as a rectangles) moving along predefined path. I've already read a few tutorials about designing a ...
1
vote
2answers
30 views

Dealing with vectors in multiple planes

Say I have my main "screen" plane, where vectors can be represented I "know"/can represent vector Q, but the only information I know about vector R is relative to Vector Q. An easy way to visualize ...
1
vote
2answers
96 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
61 views

XY rotation directions

I have a simple WASD controller to rotate the player, but if I press W and the player has been rotated by 20 degrees, it will only rotate around the x axis. Yes, it's logical, but how I should I ...
0
votes
1answer
66 views

Moving an object extremely close to the camera at a constant speed makes it visually speed up

I have a quad in 3D space (a billboard in the real-world sense) that I want to move close to the camera so the user can inspect it. The quad is defined by the 3D coordinates of its four corners. To ...
0
votes
1answer
58 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
35 views

Mapping polar coordinates to cube

I am trying map polar coordinates to points on a cube. I was able to map the front, back, left and right faces of the cube, but I am struggling with the top and bottom. Here is what I have: /// <...
1
vote
2answers
351 views

Why is sin = Y and cosine = X?

I'm new to game development in some phases and I want to understand everything I do (at least most of it) so I've started developing in MonoGames framework (XNA) and I saw a function like this. ...
0
votes
1answer
57 views

What FOV does Unity show in a 16:9 aspect ratio, when set to FOV 60?

Preamble: I noticed the FOV in Unity is only correct when the screen resolution is square, in other words when the width of the screen is the same as the height. When you add more width to the ...
0
votes
1answer
96 views

I'm having resolution issues; does my math suck?

There are a lot of scripts involved so I'm just going to give a generalized description of the process. First, a 1x1 square tile is created. Second, that tile is placed out of the way, and 16 x 10 (...
0
votes
1answer
49 views

Calculate position on Isometric grid

I created the following tile grid in unity3d: The blue dot is the absolute center point (0,0) of both scene space and tile map. Now I am trying to calculate the X/Y position of points on the tile ...
0
votes
1answer
46 views

convert gl_Position into screen coordinates

Pretty simple question I think. I need to convert model space coordinates into screen space coordinates for a special shader effect. I am of course able to just convert them into gl_Position ...
0
votes
0answers
34 views

javascript - Get x and y values from computed CSS matrix3d?

This example (which works only on Safari), uses the deprecated function webkitConvertPointFromPageToNode var point = webkitConvertPointFromPageToNode ( fieldContainerH, ...
1
vote
2answers
87 views

What are the alternatives to additive damage?

By additive damage I do not mean additive damage bonuses. I mean damage that adds up over time: New HP = Old HP - Damage Additive damage has the following properties: It is linear as damage adds up ...
0
votes
2answers
72 views

How to keep a square in front of moving camera?

I'm currently attempting to create a Lens of Truth effect like what we find in Zelda: Ocarina of Time: The Lens of Truth allows [the player] to see things that are not normally visible to the naked ...
0
votes
0answers
34 views

Get Edges of Intersection Line from Tr-iTri Overlap Algorithm

Hi I have the following code, which finds the intersection between two triangles, and returns the two points making up the intersection line (out Vector3 isectpt1, out Vector3 isectpt2). I would like ...
1
vote
1answer
43 views

Spotlight Culling. Plane vs Cone Shape

I am building forward + engine based off of partially http://www.humus.name/Articles/PracticalClusteredShading.pdf If you go to page 36 on the pdf and "spot light culling section" they mention "Do ...
0
votes
0answers
29 views

Position a camera so that top left and bottom right corners are both points in 3D space

I would like to place a camera so that it has a specific portion of space in sight. I would like to place it equidistant to two points in space, corresponding to the intended top left corner and the ...
0
votes
2answers
107 views

multiply matrix4x4 with vec4

I'm developing a game and I'd like to make model * pos4 calc (that's usual in glsl vertex shader) in cpu instead of doing it in gpu. I'm using LWJGL and for the math impl I use JOML. Anyone know how ...
4
votes
1answer
103 views

How do you make a camera look at a box and ensure all of it is visible?

In most game engines (Unity, UE4) if we select a model and press F, the camera moves and focuses to the selected model. I want to implement that for my models. I have a perspective camera and world ...
0
votes
1answer
35 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 ...
3
votes
1answer
52 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
30 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
50 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
119 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
65 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
72 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
41 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
75 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
28 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
26 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
31 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
83 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
68 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
39 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
32 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
147 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
83 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
237 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
117 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; ...