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)

4
votes
2answers
159 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
25 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
113 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
55 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
79 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
63 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
49 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
73 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
120 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
17 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
41 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
54 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
242 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
58 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
46 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
45 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
64 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
74 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
36 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 ...
4
votes
2answers
164 views

How can I manually construct a right-handed orthographic projection matrix?

I need the formula to create a orthographic projection matrix. I am using GLM math libary and DirectX11. The reason I cannot use GLM to create it is because the NDC spaces are different between DX11 ...
0
votes
2answers
34 views

Converting A 3D Rotational Vector Into A 3D Forward Heading Vector

I need to do a raycast which accepts a Vector3D StartPos and a Vector3D EndPos. I have available to me the characters position and the cameras rotation in 3D vectors. I need to somehow compute a ...
-1
votes
3answers
93 views

Shooting based off mouse position [duplicate]

I'm trying to shoot bullets where the mouse is aiming using one image as a test. I'm trying to get the mechanics like this I have some kind of algorithm to handle that but the results arn't too ...
0
votes
0answers
34 views

Calculating co-ordinates of a line/ray that's increasing in height with a known slope/radians. Height increase is also known

basically in my game I'm firing a line. The line's anchor point is at the very bottom of it, and half of its width. When I fire the line, its rotation gets set to face where we want it to go. Then, ...
4
votes
1answer
80 views

Determining a sensible gear-like hierarchy for a series of connected objects

I would like a series of objects to behave in similar manner to a series of connected gears. This means that each black object in the diagram below will rotate at a speed based on the ratio of their ...
-1
votes
1answer
85 views

Code explanation

Can someone please explain whats going on in this code written by Paul Irish I did not understand the draw(). function draw() { var time = new Date().getTime() * 0.002; var x = Math.sin( ...
0
votes
1answer
60 views

What is the optimal way to handle matrix internal data storage for interop with native graphics apis?

I'm writing a managed (c#) game engine and have stumbled on a bit of a crossroads in design/implementation regarding matrix types. Matrix types need to be optimized for marshaling to native graphics ...
0
votes
1answer
76 views

Rotating a vector around a vector in 3D space

I am trying to rotate a moon around a planet (the planet is also rotating around an axis) but I am having trouble doing so. I tried to make the model move through space like so: @Override public ...
0
votes
3answers
84 views

Bridge made out of blocks at an angle

I want the player to select 2 points (vectors). With these 2 points a floor should be created. When these points are parallel to the x-axis it's easy, just calculate the amount of blocks needed by a ...
0
votes
0answers
24 views

Map to Screen Coordinates for isometric style map with tile height of 71 and width of 110

I am aware of the coordinates to convert map to screen coordinates and back with isometric tiles with a height and width ratio of 2:1. What I need is the same for tile width of 110 and height of 71, I ...
0
votes
2answers
165 views

How do I create a knockback-movement?

I am a web developer new to game development, and with limited math knowledge. I am writing a character movement controller in Unity. The game has an isometric Diablo-like camera. The character moves ...
2
votes
2answers
48 views

How to use “weighted average easing” correctly with variable framerate?

I often use a weighted average for smoothly animating numerical values to a target value, like so: frame(dt) { value = ((value*someFactor) + targetValue) / (someFactor+1) } As you can see dt ...
1
vote
1answer
43 views

Fit a bounding box in the scene modifying FOV

Suppose I have a radius for a spherical bounding box around a mesh. My goal is to render the scene such as when the camera moves, the bounding box whose centre the camera look at, occupies always ...
0
votes
0answers
61 views

Closest distance from 3D point to vector line

First let's have a look at my little drawing: I have an origin point p1 defined by x, y and z co-ordinates, and a vector v given by x, y and z magnitude. I also have an arbitrary point, p2, given ...
6
votes
4answers
497 views

How do I convert from the global coordinate space to a local space?

Given an entity named EntityA, I want to define a local coordinate space, where the position of EntityA is the origin, its heading vector is the X axis, and the normal of the heading vector is the Y ...
1
vote
2answers
101 views

Find point in 3D plane

I have four points in a 3D space, example: (0,0,1) (1,0,1) (1,0,2) (0,0,2) Then I have a 2D position on that square plane: x = 0.5 y = 0.5 I need to find out the 3D space point of that position in ...
1
vote
1answer
44 views

How to find the points of intersection of two OBBs

In my game I need to be able to find the points of intersection between two OBBs. I'm using Separate Axis Theorem to check if there's an intersection and get the penetration vector if there is one. ...
0
votes
1answer
36 views

Scaling entity by screen height (simulating depth on orthographic camera)

i want my entities to be at 100% scaling (for example 128x128 pixels) when they are at 40% of the screen height (for example 480 pixels at 100%), so when they are at 41%, they are at 99% scaling ...
3
votes
1answer
269 views

Explain this line segment intersection code

I've been reading this article on pathfinding over polygon meshes using line-of-sight, and in the article are several code snippets. One of them, the one I'm trying to understand, is a simple function ...
2
votes
2answers
201 views

How to make a projectile align correctly with the entity that shot it

I'm developing a 2D game. In the game, all entities can rotate 360 degrees. Each entity holds an angle value, and every frame it is drawn rotated around it's center by it's current angle value. For ...
2
votes
2answers
221 views

How can I simplify this code to compute the shortest rotation between two angles?

The following code will find the shortest rotation (in radians) (from pi to -pi) that I need to apply to from to leave me with to. Scalar rotationBetween(Scalar from, Scalar to) { Scalar fromMod ...
1
vote
1answer
39 views

XY Location scaling with varying density screens

I have a phone with resolution H=1280,W=720,Density=2 I have a tablet with resolution H=1216,W=800,Density=1.331 I drew a rectangle on my phone with corners Left,Top (-1.6,1.55), Right,Bottom ...
1
vote
1answer
70 views

How do you change movement to strafe

Right now my player can move forward and backward using case 'a':case 'A': speed.x = lx * 0.1; speed.z = lz * 0.1; break; case 'b':case 'B': speed.x = -(lx * 0.1); speed.z = ...
1
vote
2answers
69 views

How to get the normal that points *out* of a polygon

In 2D, each vector (x, y) has two normals: (-y, x) and (y, -x), pointing in opposite directions. Say I have a polygon and for each of it's edges I need to get the normal pointing outwards. In the ...
1
vote
0answers
50 views

Resolving penentration after collision using Separating Axis Thereom

I implemented collision detection in my game using SAT. The detection works, but I'm trying to use the algorithm to figure out the penetration vector of the two OBBs and push them apart (before doing ...
3
votes
1answer
103 views

How can I find the tangent and normal at an interpolated point on a Catmull-Rom/Hermite spline?

I have an implementation of a simple Catmull-Rom spline. It works, but I'm trying my hardest to be able to place vertices at extrusions along the curve. For this I need the normal (and tangent in the ...
20
votes
3answers
2k views

Are there 3D projections other than orthographic and perspective? [closed]

The question is pretty much in the title. Are there notable 3D projections other than orthographic and perspective that could be used in a 3D system such as OpenGL? In particular, are there any that ...
3
votes
1answer
76 views

Make an object follow the mouse pointer with LÖVE2D

I've been trying to make a picture follow the mouse pointer with LÖVE2D. I want that the object follow the mouse, and not just be the mouse coordinates, I did that. So I toked the distance between ...
1
vote
1answer
76 views

Predicted target location [duplicate]

I'm having an issue with calculating the predicted linear angle a projectile needs to move in to intersect a moving enemy ship for my 2D game. I've tried following the document here, but what I've ...
1
vote
1answer
34 views

Predicted target location

I'm having an issue with calculating the predicted linear angle a projectile needs to move in to intersect a moving enemy ship for my 2D game. I've tried following the document here, but what I've ...