# Tagged Questions

A branch of mathematics concerned with questions of shape, size, relative position of figures, and the properties of space.

16k views

### How can I convert a mouse click to a ray?

I have a perspective projection. When the user clicks on the screen, I want to compute the ray between the near and far planes that projects from the mouse point, so I can do some ray intersection ...
2k views

### Generating spherical world from heightmapped terrain

I am using a standard heightmapped procedural terrain in my project. However, I want the terrain to appear spherical when the user zooms out. This is an attempt to simulate the appearance of a ...
4k views

### How do you turn a cube into a sphere?

I'm trying to make a quad sphere based on an article, which shows results like this: I can generate a cube correctly: But when I convert all the points according to this formula (from the page ...
1k views

### How do I make a curved surface out of rectangular blocks?

For a Peggle-like game, I want to make blocks that follow a curve, like this: The blocks would then disappear as the ball hits them. I managed to draw some horizontally, but I'm having trouble ...
543 views

### rotating an object from sourceAngle to destAngle, both 0-359, clockwise or counter clockwise?

I've got a game object i need to rotate. It's current angle is player.rotation, the destination is targetAngle, both in degress, 0 to 359. I've got a function named rotateDirection(float sourceAngle, ...
4k views

### Arbitrary Rotation about a Sphere

I'm coding a mechanic which allows a user to move around the surface of a sphere. The position on the sphere is currently stored as theta and phi, where theta is the angle between the z-axis and the ...
4k views

### 2D isometric: screen to tile coordinates

I'm writing an isometric 2D game and I'm having difficulty figuring precisely on which tile the cursor is. Here's a drawing: where xs and ys are screen coordinates (pixels), xt and yt are tile ...
5k views

### How do I use the dot product to get an angle between two vectors?

I am learning to use normalized vectors in my games. I've learned that in order to know the angle between two vectors, I can use the dot product. This gives me a value between -1 and 1, where 1 ...
2k views

### How does Unity3D lower an imported .obj vertex count?

I have a question regarding how Unity3D handles importing of .obj files. I'm importing this teapot: http://groups.csail.mit.edu/graphics/classes/6.837/F03/models/teapot.obj The number of vertices ...
4k views

### How do I find rotation in 3D based on a vector/normal?

I've been playing with Blender and Python, doing basic things like accessing vertices/normals,etc. I can get the normal of each face of a mesh. I was wondering, how can I get the rotation of a face ...
16k views

### How do you programmatically generate a sphere?

Could someone please explain how it would be possible to create a sphere vertices, indices and texture coordinates? There is a surprising lack of documentation on how to do so and it is something that ...
6k views

### How do I calculate distance between a point and an axis-aligned rectangle?

I have a 2D rectangle with x, y position, height and width, and a randomly positioned point nearby. Is there a way to check if this point might collide with the rectangle if it is closer than a ...
5k views

### Circle-Line Collision Detection Problem

I am currently developing a breakout clone and I have hit a roadblock in getting collision detection between a ball (circle) and a brick (convex polygon) working correctly. I am using a Circle-Line ...
1k views

### How to limit click'n'drag movement to an area?

I apologize for the somewhat generic title. I'm really don't have much clue about how to accomplish what I'm trying to do, which is making it harder even to research a possible solution. I'm trying ...
2k views

### Morph a sphere to a cube and a cube to a sphere with GLSL

I'm getting started with GLSL with quartz composer. I have a patch with a particle system in which each particle is mapped into a sphere with a blend value. With blend=0 particles are in random ...
556 views

### Robust line of sight test on the inside of a polygon with tolerance

Foreword This is a followup to this question and the main problem I'm trying to solve. My current solution is an hack which involves inflating the polygon, and doing most calculations on the inflated ...
571 views

### How do I calculate the distance between a point and a rotated rectangle?

This question is similar to another one about axis-aligned rectangles. However, I specifically want to calculate this for rotated rectangles. I have a rectangle with a (cx, cy) for the center ...
1k views

### How does atan2 work when getting angle of a vector?

I know that atan2 gives me the absolute angle of any vector. But it doesn't give a value from 0 to 360 degrees. Instead, it gives a value (if I'm not mistaken), between 0 and 180, or between 0 and ...
6k views

### How to determine the point of intersection of two lines? [closed]

I have two lines say P1( 0, -1, 0, -1 ) and P2( -1, 0, 0, -1 ). Since I'm working in 2D, there is no Z component. The x,y,z components are normals and the w component is the distance from origin. I am ...
3k views

### Hexagon collision detection for fast moving objects?

A object has a position and a speed vector. Usually only the position is used to check if two objects collide, this is problematic for very fast moving objects as it can happen that the object moves ...
1k views

### How can I tell whether an object is moving CW or CCW around a connected path?

Lets say we have a jagged shape: And two creatures moving along it's outline. Then we smooth the shape completely by pulling the corners out. We get this: It is easy to see now that Orange is ...
5k views

### How do I test if a circle and concave polygon intersect?

I have a polygon (sometimes convex, but often concave), and a bunch of circles with different radii. How can I find out if a circle is intersecting/overlapping with the polygon? I could split my ...
4k views

### Is the Manhattan distance monotonic when used as heuristic function?

I have a square-based map. Only horizontal and vertical movement is allowed (no diagonals). Movement cost is always 1. I'm implementing an A* algorithm on that map, using the Manhattan distance as a ...
713 views

### Algorithm for creating adjacent triangles

I have a system where you can click once to place a node in a scene. When you place 3 nodes, it forms a triangle. When you place any future nodes, it creates a new triangle by joining that node to the ...
549 views

### a flexible data structure for geometries

What data structure would you use to represent meshes that are to be altered (e.g. adding or removing new faces, vertices and edges), and that have to be "studied" in different ways (e.g. finding all ...
663 views

### How do I efficiently check if a point is inside a rotated rectangle?

Part for the sake of optimization, part for learning purposes, I will dare to ask: How can I most efficiently check whether a 2D point P is inside a 2D rotated rectangle XYZW, using C# or C++? ...
2k views

### Geometry System of Populous: The Beginning [closed]

I want to to develop a game like Populous: The Beginning with my friend. But we could not find out what type of geometry they have used for the world. We know that - all tiles have the same size - ...
222 views

### How do I interpolate around a rectangle?

I want to make a fancy animation where a point travels around a rectangle. I want to find the point's position at a time t. The rectangle is given by X, Y, Width and Height. Is there an algorithm ...
2k views

### How do I translate a spherical coordinate to a Cartesian one?

Could someone point me in the right direction as to how this might be achieved? 3D math / geometry often throws me. I'm looking for something like this (ideally in C#): public Vector3 ...
13k views

### How to calculate a 3x3 rotation matrix from 2 direction vectors?

I've got 2 direction vectors, for the X axis and the Y axis of the object. How do I calculate the rotation matrix of the object using these?
141 views

### Generate Geodesic Sphere from Hex and Pentagons

I have two polygonal meshes, a hexagon and a pentagon (They are tiles in a strategy game). I want to use them to construct a geodesic sphere ...
237 views

### How do you calculate if a line is facing a curve?

Given the 2 points describing a line segment, and the 3 points describing a quadratic bezier curve, how do you calculate if the line is facing towards or away from the curve? The line has a fixed ...
2k views

### How do I align the matrix used in SpriteBatch and the matrix used in BasicEffect?

I'm writing a Windows tool that uses XNA and allows the user to place textures on the screen. I'm using a 'camera' for the SpriteBatch used to draw the textures, e.g: Matrix matrixForSpriteBatch = ...
2k views

### How do I restrict the movement of a point to within a radius of another?

I have a situation where a sprite's center point needs to be constrained within a certain boundary in 2D space. The boundary is circular, so the sprite is constrained within a radius. This radius is ...
1k views

### Generating geometry when using VBO

Currently I am working on a project in which I generate geometry based on the players movement. A glorified very long trail, composed of quads. I am doing this by storing a STD::Vector, and removing ...
1k views

### Repairing back-facing triangles without user input

My 3D application works with user-imported 3D models. Frequently, those models have a few vertices facing into the wrong direction. (For example, there is a 3D roof and a few triangles of that roof ...
724 views

### Converting between Spiral Honeycomb Mosaic and axial hex coordinates

There seems to be quite a lot of logic in dealing with hexagonal grids using a system of axial coordinates like the one described here. In doing some reading about hex grids, though, I ran across the ...
3k views

### How do I find the circumcenter of a triangle in 3D?

I want to find the circumcenter of a triangle. Wolfram only shows how to find the circumcircle of a triangle in R2. How can I find the circumcenter of a triangle in R3?
636 views

### How do I make a low pass filter (average of readings over time) for compass?

I'm making a prototype for android that pulls compass data from the phone. I want to stabilize it so it is less jerky, by taking the average of the last couple of readings. I have done this for ...
167 views

### trapped inside a Graph : Find paths along edges that do not cross any edges

This is a graph based platformer level and the round shapes are creatures. I am looking for a path traveling along edges that does not cross other edges(To simulate the creature crawling on the ...
526 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 ...
603 views

### Adding tolerance to a point in polygon test

I've been using this method which was taken from Game Coding Complete to detect whether a point is inside of a polygon. It works in almost every case, but is failing on a few edge cases, and I can't ...
3k views

### How to move an object along a vector

Let's say I got an object A and object B in a 2D game. I create a vector leading from A to B. It's name is AB. How can I make A move along the vector AB and reach B? One way I was thinking of doing ...
1k views

### How to generate AABB, OBB & Sphere from polygon soup

How can I generate AABB, OOBB and Sphere from a polygon soup, where the bounding volumes are defined as follows: AABB should be specified by min(x,y,z) max(x,y,z) OOBB should be specified by ...
126 views

### How to linearly “blend” between multiple 3D points?

I have a set of 3D points that I need to "blend" between. Lets say I have points [A,B,C] and I have the amount I want to blend each as [0.5, 0.2, 0.8], how can I blend between these points with the ...
122 views

### Rotate coordinates back after rotating game context (geometry)

To achieve something similar to the image below using HTML5 canvas one can simply write the following: var TO_RADIANS = 0.0174532925; context.translate(30, 20); context.rotate(30 * TO_RADIANS); ...
86 views

### Is there a way of moving the transform of an object relative to it's geometry

I have a number of objects (mostly prefabs) that have their transform origin in inconvienient places such as about 1 unit to the left of the actual geometry or somewhere inside an object where it's ...
264 views

### Moving OBB vs. triangle intersection test

Requirements: to write a test function that, given a moving OBB (oriented bounding box) and a triangle, returns true whenever the OBB hits the triangle. The OBB is described by its half extents (h1, ...