# Questions tagged [mathematics]

Mathematics questions deal with the arithmetic, geometry, calculus, formulae and other calculations used in the development of a game.

141 questions
60 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 ...
116 views

### How to move a portion of bezier/spline curve along its complete bezier/spline curve?

Based on the image below, I have a curve (orange) which is a bezier sub-curve of an original curve (longer black curve). The original curve consists of a number of cubic bezier curves joined together. ...
47 views

### Slot Probability Function

Please can someone point me in the right direction. I'm working on a slot game. that I'm having trouble figuring how to implement the probability function for. The game has a set of symbols that bets ...
162 views

### How to draw a Voronoi Splitscreen view in GMS, where each player's screen area is a polygon shape?

I'm trying to implement the Voronoi Splitscreen effect that Squirrel Eiserloh described at GDC 2016, and I'm having trouble figuring out how to 'clip' the rendered scene for one player along a ...
85 views

### How to implement a pannini projection in opengl?

I have read about the pannini projection, which involves (I think) projecting a scene onto a cyclinder instead of a rectangle. How can I implement this projection in a vertex shader? Blinky is using ...
309 views

### How to target moving object in 2D game

I am working on targeting system for 2D game. Two objects move in space. Each one have Position and Velocity vector. Ship object shoots moving objects in space. Ship can shoot in any direction, but ...
133 views

### How do you find the collision between 3D boxes and 3D QUAD face meshes?

I have an axis aligned bounding boxes for 3D object collision, but I have a complex 3d mesh that's divided into 3d faces so I want to check for bounding boxes and collision with the faces of that ...
79 views

### Handling a smooth movement over slopes in a worms like game

I currently have a worms like game with the worms style pixel perfect terrain destruction. Its working well for pushing things around and watching them fall, but for the players movement it feels like ...
30 views

### Defining a coordinate system for player residing in another coordinate system

I'm making a game and I wanted to simplify some code by taking advantage of linear algebra. I'm a little stuck. Let's say the player (green triangle) resides in a coordinate system where the x-axis ...
85 views

### Bullets moving with the camera, not the world, Java 2D

I'm building a simple 2D Top-Down shooter game in Java. I simply cannot get this to work: I'm moving camera and world differently, world is moving when needed (when not in one edge, so it gives nice ...
93 views

### What is the formula for the collision of two “stretched spheres”?

In Smash Bros Melee, hitboxes aren't perfect spheres or boxes. They are, instead, a shape that looks like a continuous line of consecutive spheres: I.e., the geometry can represented as: ...
181 views

### Filling Closed Shapes

Game Engine : Unity 5.1 Developing on Windows 7 Hello, I am using Vectrosity to draw some some shapes on screen run time. I also need to fill these shapes and none of them are really trivial shapes. ...
317 views

### 3D Zoom To Mouse Cursor accounting for Change in Camera Pitch

Overview: Simply put, I'm trying to make a zoom to cursor algorithm. This would normally be very simple, but the implementation of the camera is making it difficult. As the camera zooms in and out, ...
59 views

### Weird warping with per-vertex normals

I've had this little problem for a while now, where for some reason my calculations for per-vertex normals results in a weird distortion or warping, skewing my lighting, shading, and reflection passes....
238 views

### Hex axial coordinates to table coordinates conversion

I am developing a browser game based on a hex map. I am storing my data based on axial coordinates system. I developed a function which shows me axial coordinates of hexes within ...
270 views

### How to calculate a quaternion rotation between 2 vectors with a specific final up vector?

I know you can calculate the quaternion rotation between 2 vectors with something like this after all the optimizations: ...
37 views

### get tetrahedron centroid velocity if vertex velocities known

If i have a tetrahedron and i know the velocities of the 4 vertices, how can I find the velocity of the Centroid? I know how to get the result if i know the velocity of the Centroid (i can use ...
153 views

### How to aim with a spaceship in 3D considering its angular momentum?

So I have a spaceship and I have 6 degrees of freedom. At a given moment the following vectors are known of the spaceship: Local forward. Local up. Local sideways (may be implied from the previous ...
181 views

### Stereo 3D: drawing 2D elements at apparent screen depth

I'm developing an application making use of DirectX11's stereoscopic features. At such I am not relying on nVidia's automatic implementation. That means I have to replicate a way to render 2d elements ...
732 views

### Quaternion to direction vector - flipping

I've kinda solved this myself by adapting the Camera::setDirection code from OGRE to work for my need: Now I have the following code: ...
27 views

### Circle ceases to be a circle when radius is below a certain value

I'm using the LineRenderer component to draw a circle. It renders fine, but it's a little too large. The smallest I can set the radius is .06f. If I try to set the radius to anything less than that, ...
60 views

### algorithm to change the center of the image

I need and algorithm in Java if possible to change the center of the image when scaling.What is happening to me is represented in the first image: when I scale the image the image scale according to ...
46 views

### Center of Mass for Convex shape in 3D

For an arbitrary convex shape in 3D, how can I calculate its center-of-gravity? I have face-normals, and the vertices for each face. @Ocelot No, it most certainly is not the average of the vertices, ...
51 views

### Why are coordinates converted to [-1, 1] during mouse picking?

I am working on my first 3D game, which contains several vehicles placed on a board. I want to implement mouse picking of the vehicles. I found this great tutorial and used its code. But I don't ...
107 views

### How do I create the formula for calculate the damage of a skill

I'm trying to calculate the output damage of a skill. The skill can go up from level 1 to 100, it can scale with own levels and the attack of the character. Here some parameters Edit: I need a ...
181 views

### Plotting 2D map coordinates to OpenGL 3D projection

I’m trying to convert a 2D map created in my map editor to a 3D plotting with OpenGL. This is my map generated in my map editor: Those vertices are relative to my Cartesian origin world coordinate (...
44 views

### Get world position from Fragment Depth

I am trying to write the depth value in a G-buffer pass and then read it later to determine the world-space location of a fragment. I have this shader which renders my G-buffer pass ...
51 views

### Get world position from depth buffer

I have a buffer I am rendering gl_FragDepth (remapped to range 0-1) to a color buffer (instead of color) in OpenGL I would like to, in a second pass, read this ...
63 views

### Converging at position and angle using motor-based rigidbody movement

I am given a rigidbody positioned in $\mathbb{R}^2$. It is a box of length $l$ and height $\epsilon$. The position of the box's left center is described by $\vec{p}$, and its angle from the x-...
225 views

### Has there been any research done on ideal values for loot drop tables?

I doubt many people want to grind for an item that has a 0.00001% chance to drop from a boss that takes 30 minutes to kill. I'd imagine there are certain factors that play into how rare an item should ...
431 views

### Unity - Quaternion.AngleAxis for two axes

I am creating a character controller where the camera follows the rotation of the player, and allows the user to click and drag to rotate the camera around the player, and lerps back when its released....
262 views

### Setting relative anchor point via matrix

The page at https://webglfundamentals.org/webgl/lessons/webgl-2d-matrices.html provides an example for rotating around the center of the image: ...
104 views

### Point System For Answering Categorized Questions

We are currently developing a gamified e-learning website. The website will have a point system where the users can gain points by doing either asking or posting questions. Questions are grouped by ...
423 views

### SceneKit-Convert a rotation vector into rotation matrix

I'm very new and I'm studying this ARKit code from RPasecky/CubesInSpace on github where he/she convert the point of view 's rotation vector into a rotation matrix ...
76 views

### how to debug calculating tangent space

[][]2 there's problem calculating tangent space and look.... it seems there is no problem with UV code and my shader is 100% no problem. I just copy and pasted tutorial code which works well.. I ...
29 views

### Algorithm for clipping convex quadrilaterals

I'm dealing with hardware that uses quads as its polygonal primitive. Not triangles. A triangle can be expressed by setting 2 of the 4 equal to each other for a degenerate quad. For the 3D engine, I'...
26 views

### Interpolating bent textrues

I am currently making a pressure heat map that will be overlaid on a bent shape (let's say cylinder). I am using a 2d texture that is mapped to the object. The pressure points are also mapped to the ...
111 views

### How to line up rigidbody velocity with speed of moving floor

So, I have a player who remains in the same X position. the floor moves from right to left underneath the player, and I am using tiles of 1 unit. Here's my jumping stuff: ...
691 views

### Applying Rotation Vector to OpenGL camera or “view matrix”

I'm building an augmented reality application where I want objects on the screen to move with respect to the orientation of the phone. For example, if the phone is held still - the object stays at the ...
167 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. ...
180 views

### 3D software-based engine projection issues

I have been writing a 3D soft-engine for a little while and I have gotten it a reasonable position but recently noticed a bug that I can't seem to solve. When I am rendering a few cubes as a test, if ...
45 views

### Convert box to matrix

I have a box (non-rectangular cuboid?) and would like to convert it to a matrix such that when a point inside the box is multiplied by the matrix, a vector is returned that describes the relative ...
69 views

### My orbit code produces the wrong results

I have a GameObject called "Sun" in the sky. A game object called "GameManager" keeps track of time in the game, it is responsible for updating the hours and days. For my sun I do something like this ...
38 views

### Mathematics help. Preliminary grid checking assistance. (Supercover Z)

Problem outline: A ray passes through a gridcell. The gridcell's max z's must be compared to the ray segment's min z. This is the preliminary check, so it must be quick. 2 values must be obtained, the ...
336 views

### Jumping on meshes in Babylon.js

So I want to make it possible for players to jump on objects (meshes) that are somewhat lower than the players camera. I have set the checkCollisions to true but i can't seem to jump on any objects (...
783 views

### How to fix my camera angle in ROBLOX?

I am trying to make my own camera in ROBLOX. Here's my problem, I am using an inverse function to make the camera look nice and smooth but it only works on the x axis in the positive side. Here's an ...
258 views

### Rotation of a point around axis using quaternions

I have a simple processing program to rotate a point around arbitrary axis but it stops after a bit. I'm trying to get full rotation of the point around the axis. ...
34 views

### A question about Decal projection

From my understanding, there are several different ways to implement decals, from screen space, to copying geometry, but I can never find an explination of it's math. So what exactly is the math ...
1k views

### Euler angles to directional vector

I wanted to implement a directional light system in my game, and instead of passing the direction to the light, I chose to use an angle, and only later convert it to a directional vector, so it is a ...
187 views

### How to find or compute or look for overall/max RPM by simply checking for rotation?

I find it hard to determine the wheel RPM since I'm only making a simple 2D game of rotating object via Z-axis. I wanna try this solution but I got no change since I'm trying to find the RPM from a ...