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
1answer
40 views

Calculate slope for linear interpolated movement

I want to move rectangles to their targets the "smooth" way with linear interpolation. I hope this is right. float slope(float x1, float x2, float y1, float y2) { return std::abs((y2 - y1)) / ...
0
votes
1answer
43 views

Normalizing a homogeneous 3d point

As I've seen corruption in geometry, why is it a bad idea to normalize a homogeneous (divide by w) the vertex position returned from vertex shader?
0
votes
0answers
14 views

Could you advice me which book or books should I go for?‏‏ [on hold]

I am into game development and I am looking to buy Physically based rendering:From theory to implementation 2nd edition. I want to create my own rendering,lighting and shading solution which will be ...
0
votes
1answer
74 views

Ray->triangle collision math seems to not work?

First time asking, pardon any mistakes I make :) I am programming a game from scratch, and the collision detection is giving me issues. I have AABB in place to check proximity, and if that reacts, ...
0
votes
0answers
18 views

DirectX11 Maya Like Insertion

I'm currently trying to building a game editor and wish to have a way to insert models by clicking on the view space. I would like this system to act much like how Maya inserts polygon models (default ...
0
votes
0answers
45 views

Developing a mathematical formula for fold drive physics in Space Game [closed]

I come to you with a mathematical dilemma I'm having for a computer game I'm working on, called Warspace. In this universe, interstellar travel is achieved through a Fold Drive, which warps or "folds" ...
1
vote
1answer
49 views

Understanding constant acceleration in terms of game physics simulation

There are various integration methods that can be used for games. I am trying to write a simple physics engine deciding between semi-implicit Eular and Verlet variants. What I don't understand is ...
-3
votes
1answer
52 views

Translate a point on a circumference [on hold]

If point A is r units away from point O, how would i get a point B which is also r units from point O, but is also d units away from point A (translate d units on the circumference)? I know this is ...
1
vote
1answer
23 views

Vector magnitude in orientation

First, a quick overview of my problem: I have a game entity which has a quaternion to represent its rotation/orientation. It also has a 3D vector in world space for its linear velocity. From the ...
2
votes
2answers
103 views

How to calculate a 3D orientation from 2D vanishing lines on an image?

Let say I have a image that represent a 3D scene. I did not have the 3D camera orientation of that scene (left, up and forward vectors) and i'd like to calculate it. On that picture, I draw the ...
0
votes
2answers
56 views

Rotating point around another point

I can't manage to rotate point around another point. I did some searching around google and found algorithm that should work and it kinda does but it also moves the point I am rotating closer to ...
5
votes
4answers
1k views

What is the simplest way to calculate distance in a 3D environment?

What is the simplest way to programmatically calculate difference between two points in a 3D game environment? I am trying to sort a list of light sources by how close they are to an entity, so that ...
0
votes
1answer
99 views

Vector-based Pong-ball bounce calculations

I'm making a 2D game with pads and balls, sort of like Pong, in Unity 4.6.1. The calculations, however, won't be (very) Unity-specific. The pads are going to appear in various rotations, and therefore ...
1
vote
1answer
55 views

“aim at” in 3D space algorithm

I'd to calculate the cartesian rotate values of "aiming" one point at another in 3D space. For example, assuming rotation order of XYZ: Point A is at [0, 0, 0] Point B is at [2, 2, 0] If point A was ...
0
votes
1answer
37 views

How to get quaternion from two orthogonal 3D vectors?

I have a unit vector representing the direction I want to "look" and a unit vector for up. They are orthogonal. How can I get the quaternion that represents that orientation from those two vectors?
1
vote
1answer
69 views

How do I model diffusion and heat?

So I'm trying to solve a heat/diffusion equation for a continuous space, but I'm not opposed to a grid solution. I'm a little short on the maths needed but have made it work so far. If I model ...
0
votes
1answer
40 views

How to reposition a bouncing ball after it has passed through a surface

I have a bouncing ball which can collide with lines of a random slope. The ball passes through the lines a bit and I need to set the ball back some distance from the line. The ball (defined by ...
0
votes
1answer
60 views

Separation of axis theorem implementation at normals

This might be more of a math question, but it relates to the development of a simple physics engine I am trying to create. I have been stumped on this for about a week now, and have been unable to ...
2
votes
0answers
86 views

How to construct the marching cubes tables algorithmically?

I want to implement the marching cubes algorithm from scratch, but I'm stuck at the polygon generation phase (building edge loops with correct orientation and triangulating them). Obviously, I should ...
5
votes
5answers
1k views

How can I test whether points are within a polygon?

I have 2D-points, which boundaries depict a polygon. The points are at integer positions (no fractions possible). Now I want to build an enumerator in C# that returns all points that are inside the ...
0
votes
1answer
37 views

Launch Velocity for Simple 3D Projectile [duplicate]

This is a pretty easy question, but I can't quite figure out the answer. I have: The initial position of a projectile. The gravity vector. The (stationary) target I want to hit. A maximum launch ...
1
vote
2answers
49 views

Translating Objects in Worldspace

Given the worldspace coordinates of a collection of arbitrarily positioned objects, how do I translate them while preserving their relative placement? For instance, I have a table and a few bowls that ...
4
votes
1answer
161 views

How to calculate a direction vector for camera?

I have a vector that describes change in movement, and I have a 3d-vector, m_rot, that describes a rotation given to an object. I want to calculate a direction vector using both this data. How to ...
0
votes
0answers
23 views

Connecting a model's joint to the joint of another model

I am trying to figure out the math behind orientating and translating a model so that a specified point on the model will connect with a specified point on another model. For example, given the ...
0
votes
2answers
90 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 × ...
1
vote
3answers
80 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
16 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
45 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
38 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
51 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
104 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
88 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 ...
2
votes
1answer
84 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
83 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
56 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
89 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
88 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
35 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
72 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
54 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
183 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
178 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
107 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
56 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
15 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
82 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
161 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
117 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 ...