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
votes
0answers
14 views

Perspective based Isometric Projection

So i am currently developing a game and i am trying to come up with a solution to this problem and i though you guys could help. So i am developing a Isometric based game that will be in a 3D space ...
0
votes
2answers
62 views

Trajectory of a spinning ball

How do I would precalculate trajectory of a kicked ball, when it's spinning? I'm applying spinning using simplified Magnus effect every frame like this and it works: acceleration += swerve × ...
0
votes
0answers
19 views

looking for JavaScript physics engine [on hold]

I am looking for a simple JavaScript Physics engine that meets the following requirements: NEEDS: ~aabb collision detection ~solid bodies ~gravity ~velocity and acceleration PREFERRED: ~ability to ...
1
vote
3answers
66 views

How do I interpret the dot product of non-normalized vectors?

I know that if you take the dot-product of two normalized vectors, you get the cosine of the angle between them. But if I take the dot-product of two non-normalized vectors (or one normalized, one ...
18
votes
5answers
2k views

How can I come up with a simple diminishing return equation?

There are formulas out there for a diminishing return equation; however, those usually involve exponential. What other ways are there for coming up with such an equation? Take, for example, the ...
0
votes
0answers
13 views

Robust algorithm for ray-isosurface intersection (with depth discontinuities)

For Dual Contouring, I need to calculate the precise intersection '(zero-crossing point') of any line ('segment', 'ray') with the given isosurface ('distance field', 'density source'). The algorithm ...
0
votes
1answer
37 views

Rotating a 3d vector around an axis using sines and cosines

I am trying to represent a 3d cone light's direction using only 2 variables. Right now I represent it with two points (6 variables) but I know that the direction in 3d space can be represented by two ...
0
votes
1answer
25 views

Problematic cameraposition (Eye = (0,0,0), at=(0,-2,0) and up = (0,1,0))?

I am taking a course in computergraphics and we talk a lot about OpenGL and the math you need to do everything OpenGL does "by hand". A Question which was asked in an old exam (I am preparing at the ...
-1
votes
1answer
40 views

Simulating aircraft movement with DirectX 9 [closed]

How would I go about simulating a planes movement in DirectX 9 using transforms (i.e. matrices). For example flying around an open space. When it moves it faces the direction it is going and ...
2
votes
1answer
83 views

Weird effect when generating gradients for height map

I am experimenting with generating height maps using radial gradients and perlin noise, using a technique I found here: ...
3
votes
1answer
76 views

Fastest way to find closest triangle of mesh from specified point

I have two triangle meshes (let me call them A and B). The meshes may be really big (10.000 - 100.000 polygons). I want to find for every point in A the closest triangle from mesh B. Is there fast ...
1
vote
1answer
73 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
74 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) ...
12
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
53 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
52 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
61 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 ...
0
votes
1answer
33 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
62 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
40 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
142 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 ...
1
vote
1answer
146 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
64 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
47 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
12 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
79 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
132 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
109 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
77 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
42 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
160 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
66 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
84 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
166 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
137 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
861 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
83 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
90 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
271 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
36 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
128 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
163 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
99 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
79 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
99 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
147 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
37 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 ...