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
53 views

How can I position a sprite in the same spot across different screen sizes?

Taking into account the multitude of screen sizes and resolutions, is there a way I can position a sprite so it's at roughly the same spot on every iOS device? Doesn't matter if you are using ...
0
votes
1answer
59 views

Formula to measure uv-mapping distortion

Does anyone know a simple way of calculating (offline) the amount a texture is distorted when mapped to a triangle like the following? Vertex Position UV Coordinates A (Ax, Ay, Az) ...
10
votes
1answer
2k views

How do I tell if my enemy can see my player?

Given a player and an enemy with position, and given the direction vector of each, how can I tell if one can "see" the other? In other words, how do I test if one position with direction is in front ...
0
votes
1answer
49 views

Gravity: Slow down on ground approach

I'm looking for some math, nothing language dependant. "Standard" gravity for a character in a 2D game would go something like this: if player.y > ground.y { player.velocity.y = ...
0
votes
1answer
30 views

Scaling a UI bar for progress in Unity

I have created a progress bar inside Unity for one of my energy systems. The bar progression works fine. Its just a plane pivoted on one of the faces so scaling it in x axis makes it progress further ...
0
votes
1answer
51 views

Lookrotation of a gameObject in just one axis

So I am trying to orient a gameObject ( house in the picture below) which is nothing but a plane and has a 2d texture on it as you see below. The whole game is made on a hex sphere. I am using ...
-1
votes
0answers
29 views

Adding Spread to Guns

I'm creating a FPS, and I have a Coordinate Frame with the barrel's position and rotation. I want to add spread to the guns, and from what I understand the best way to do this is to generate a ...
0
votes
1answer
27 views

Percentage of object inside a moving rect

The idea is that I want to get a percentage of the position of Rect2 in relation to Rect1. In the picture, it would be about 75/80%. Rect2 never leaves Rect1. I move Rect1 around all the time, so it ...
0
votes
0answers
58 views

How to get drawing offsets for an isometric camera

I do have some semi-working code, but I'm really stuck on getting everything to align to the screen properly. Here's my current, broken solution in Javascript: //ts = tile size (i.e. 64), th = ts/2, ...
0
votes
0answers
33 views

Triangulation of “polygon with holes” for NavMesh

Just for fun, I am working on a little side-project: As a first step, I want to be able to build a grid-based world (think Dungeon Keeper), generate a nav-mesh for this world and then let agents ...
3
votes
1answer
120 views

Mixing Perspective and Orthographic Projections?

I'm going to start with some background, so jump to my question at the bottom for the TLDR version. Problem: In a Japanese 4gamer article (english translation via Chev on Polycount) explaining some ...
0
votes
1answer
107 views

The math of normal mapping without a dot product

As far as I understand the technical details about a good normal mapping they go like this: everything gravitates around the concept of vertex the artist provides an RGB image and an UV map, the UV ...
1
vote
0answers
49 views

Aligning a gameObject to position and normal of another gameObject inside Unity

So I am instantiating a GameObject (the one with cities and trees in the image below) and trying to align it to a hex tiles on a Sphere. So after I instantiate the gameObject, I ray-cast to get it ...
1
vote
2answers
43 views

Offset during zooming to keep object within boundries

I have a simple zoom feature which lets the user zoom in and out. I'm having an issue how ever when i zoom out the object gets smaller to the point that the boundaries become broken. The idea is the ...
0
votes
0answers
8 views

Transform screenquad around object's view space boundaries (GLSL)

Im not sure how to ask this, but essentially I am looking for a way to optimize rendering screen quad lights per object. I have a deferred renderer that draws directional lights onto a screen quad. ...
1
vote
2answers
76 views

Required number of images for octagonal tiles

I'm planing to write a game based on octagon tiles. Currently I'm wondering how many images I really need. That is something about graph theory, I know that, but not only. I want to connect each side ...
0
votes
1answer
124 views

How to determine the distance between a point and a rotated rectangle

This question is very similar to How do I calculate distance from a point to a rectangle?. But that question assumes that the rectangle is axis-alligned, or not rotated. So just like in that ...
2
votes
2answers
102 views

Calculating gameObjects hit by a directional light source

I am trying to figure out in my current game whether a gameObject is lit by a directional light or not. Below is my image inside the Unity game engine As my game runs around a Day/Night cycle, I ...
0
votes
1answer
63 views

3D Translations relative to 3D Rotations

I'm trying to program camera movement to be relative to camera rotation. (Forward is always forward, regardless of pitch, yaw, and roll) I want to be able to move forward, backward, left, right, up, ...
0
votes
1answer
37 views

using rperp or perp to find perpendicular of a vector

i have code local coordinate Vec2 velo = Vec2(100,0); Vec2 Heading = velo.getNormalized(); Vec2 side = Heading.perp(); Vec2 trans = Vec2(12,12); then i can generate toWorldCoordinate for trans ...
0
votes
1answer
28 views

Determining if a Point3D passed another

I have 2 points A and B in 3D space (say of type Point3D). B needs to travel towards A and then stop either when it reached or passed B. The direction between the two points is known (can be easily ...
0
votes
0answers
128 views

Creating a arc path connecting two GameObjects in Unity

I am working on a game on a spherical surface which first of all is a big challenge in itself. I want to create a path on an arc which connects two points ( seen in the image ) and show an arc path ...
0
votes
1answer
62 views

Implicit Functions and extracting an isosurface

I recently discovered a paper on Dual Marching Cubes which produces a much reduced poly count to other methods like Dual Contouring and Marching Cubes, however a recurring theme when reading these ...
0
votes
1answer
69 views

Isometric View of “Voxel-Style” Terrain

Suppose you have an arrangement of data for a terrain set up like this: terrain[layer][cart-x][cart-y]. Each location (ex. terrain[0][0][0] for the top left corner of the lowest layer) in the array ...
1
vote
1answer
147 views

Mouse click movement

I need to make realistic human movement (3D) using mouse click. Get mouse click point using Raycast. Smoothly Slerp to LookRotation. Move transform.forward. Everything works fine, except I have ...
0
votes
2answers
130 views

Explaining vector math for a pendulum camera

I came across a code that I guess is doing a pendulum camera, that's the class name. I would like to know the math behind that. I would like also to know how to decipher those stuff in game math, ...
3
votes
1answer
840 views

Converting time of day into a smooth day/night variable?

I'm trying to make a smooth day/night cycle for a game project that I've been working on. I've already set up a clock that adds deltaTime to seconds, wraps seconds to gameMinutes, etc. The issue that ...
2
votes
1answer
47 views

Libgdx : point that scrolls on the edge of a circle

I'm not very familiar with libgdx vectors. I want to create my own joystick-controller and I want to know how can I find the coordinates of B by using Vectors. I can calculate the radius and I have ...
0
votes
2answers
80 views

Getting neighbors of hex tiles in 3D space

I have a hex tiled model like attached below. Each of the hex tiles are separate objects meaning I can access each of the hex tiles individually inside Unity Now in my program I want to be able to ...
0
votes
1answer
113 views

Finding a vector perpendicular to a current vector

Assume, that we have a player that has a vector direction. We have an enemy, that is shooting a player. And the task is to find out from which side the enemy is shooting. I know the algorithm, how to ...
6
votes
2answers
248 views

Can someone explain dual contouring?

I've been trying to understand voxel rendering and have been looking at dual contouring (DC). So far I understand this much: Run a density function for a set of grid points (i.e noise function) ...
2
votes
0answers
33 views

Calculate required resolution

Lets say I have a rectangle with width x and height y. Then there is transformation matrix T. Now, how using only those data can I estimate minimal resolution of texture (that is its width and ...
3
votes
3answers
124 views

2 component unit vector

Is it possible to store a 3d unit length vector with only 2 components, for example as coordinates on a unit sphere? It seems possible but I have never seen anyone do this. Would this be at all ...
1
vote
1answer
135 views

Usage of math.Atan2 in a 3D coordinate system with Unity

I have a simple question on usage of math.Atan2 function with Unity in a 3D environment. I found this code on Unity's documentation for Math.Atan2. I changed it a bit to fit my needs. Vector3 ...
0
votes
1answer
96 views

Gun Bobbing Algorithm Math Explanation

I stumbled across this really neat algorithm which I don't fully understand. It simulates a camera's bobbing effect commonly witnessed in first person shooters while running/walking. I'm mainly unsure ...
1
vote
0answers
65 views

How to rotate enemies on 2D radar and clip them to circle shape? [duplicate]

I've been working on implementing a 2D radar for a 3D game lately, it's working fine in a very basic version. This is what is looks like: It works by transforming the 3D coordinates of the enemies ...
1
vote
1answer
64 views

Scale around a point

I am trying to create an image editing application for the purpose of generating UV maps in my own format. I am currently working on scaling the image for the purpose of zooming. I can get the image ...
2
votes
1answer
95 views

Screen coordinates to isometric coordinates?

I know this has been discussed here before, but I couldn't find an easy solution for my particular problem. I have a tile system and I'd like to convert screen coordinates into isometric tile ...
1
vote
3answers
137 views

How do I generate solar systems for a 2d universe map, but still look random

I need to generate 64 systems separated into 16 sectors, each with 4 systems. Each system must have another system within 10 units in it's own sector, but no closer than 3. One system in a sector ...
1
vote
1answer
32 views

Camera world matrix to view matrix

I've been working on a game engine and I model every object in my scene graph as an "entity" this includes my camera. My camera therefore has a position and rotation in world space and at the moment ...
0
votes
1answer
65 views

Computing Field-of-View from window dimensions

I'm looking into computing the vertical Field-of-View (FOVy) based on the projection parameters of my camera. From this source, I've found an equation that seems to work. float ...
0
votes
1answer
56 views

Is the rendering of distorted point clouds more complex?

I have two point clouds of n points: A dense ball-shape point cloud with many points inside A spherical point cloud with points on its surface. Is there (really) any difference between rendering ...
3
votes
4answers
263 views

RPG like hit points growth algorithms help

I am currently making an XNA game in C#. I want to increase health as the player level up. I am currently using this equation. MaxHealth = Convert.ToInt32(100 * Math.Pow(1.17, level - 1)); Its ...
2
votes
1answer
59 views

Impact of object's statistics on the rendering

Consider two 3D objects with n points and n triangles. One of the objects has a smooth surface such as a ball or a box, and the other object is like a fuzzy onion-layered object with large ...
1
vote
1answer
47 views

Rotating a square rendered on a Bitmap

I'm writing a Software Renderer for fun/learning. Basically, it's just a giant array of integers which contain hexadecimal values (representing colour) that are rendered to the screen.... int ...
1
vote
1answer
67 views

Compute billboard rotation

I'm trying to compute a matrix to have object always facing the camera. For the moment, my result look pretty good, the problem is that my original billboard scale isn't preserved (Every billboard ...
2
votes
1answer
82 views

AABB implementation

I have seen in some texts and tutorials on the web where an AABB is implemented as a position vector and then half-width and half-height vectors. What is the advantage in using the half-width and ...
1
vote
1answer
91 views

How can I test if an oriented rectangle contains another oriented rectangle?

I have the following situation: To detect whether is the red rectangle is inside orange area I use this function: - (BOOL)isTile:(CGPoint)tile insideCustomAreaMin:(CGPoint)min max:(CGPoint)max { ...
0
votes
1answer
39 views

Find normal based on rotation?

Given the XYZ rotation of an object, e.g. (90,0,0), how can I find the object's normal assuming the object is pointing along it's local Z axis? In the above example the desired result is (0,1,0). ...
0
votes
0answers
29 views

Parabolic throw with set Height and range (libgdx) [duplicate]

Currently i'm working on a minigame for android where you have a rotating ball in the center of the display which jumps when touched in the direction of his current angle. I'm simply using a gravity ...