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

learn more… | top users | synonyms

28
votes
6answers
2k 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 ...
27
votes
4answers
2k views

Why does my object move faster at 45 degrees than at 90 degrees?

I have objects in my game that move faster at 45 degrees then at 90 degrees. Each object has Point (x,y) position Vector2D (x,y) direction Int speed And what I do during a update is that new ...
25
votes
1answer
2k 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 ...
23
votes
4answers
2k 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 ...
21
votes
4answers
2k views

Is there a 3D equivalent of hex tile maps?

Probably the biggest advantage of a hex-based versus square-based map tiling is that the center of each hex has the same distance to all its neighboring hexes. Is there a similar shape that tiles this ...
18
votes
5answers
716 views

Moving CW or CCW?

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 ...
14
votes
3answers
6k 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 ...
14
votes
2answers
4k views

How to find if circle and concave polygon intersect?

I have a polygon (sometimes convex, but often concave), and a bunch of circles with different radius. How can I find out if a circle is intersecting/overlapping with the polygon? If it makes it ...
14
votes
4answers
582 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 ...
14
votes
3answers
531 views

How do you calculate the nearest point on 2 curves?

Given the points of a line and a quadratic bezier curve, how do you calculate their nearest point? .... Similarly, given the points of 2 curves, how do you get the nearest point?
11
votes
2answers
3k views

Are the Minecraft animations hardcoded into the game?

I would like to know how the animation system works in minecraft. I get a feeling that all the mobs are hardcoded into the game. Did notch really sit there and create the matrices for all the ...
11
votes
3answers
600 views

Are the first three values that describe a 3D plane actually a 3D vector?

A 3d plane is typically defined as a,b,c,d. Are a,b,c actually the x,y,z coordinates of a 3d vector, with d defining the rotation of the plane, something like axis-angle rotation data?
11
votes
2answers
2k 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 ...
10
votes
5answers
652 views

How would one determine the length of a path?

I have a game that requires each player to move along one specified path. I draw the path using B├ęzier curves. How can I determine the total real (not linear) length of the path and the distance that ...
10
votes
2answers
455 views

World Bounds - (0, Size) or (-HalfSize, HalfSize)?

When creating a game space in which to move, draw and collide objects, is it better to have the (0,0) point, or the (0,0,0) point, be in the very center of your space, such that the bounds of the ...
10
votes
2answers
634 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 ...
10
votes
2answers
10k views

converting 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 ...
9
votes
1answer
3k 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 ...
9
votes
4answers
378 views

How can I find the largest sphere that fits inside a frustum?

How do you find the largest sphere that you can draw in perspective? Viewed from the top, it'd be this: Added: on the frustum on the right, I've marked four points I think we know something about. ...
9
votes
1answer
548 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 ...
9
votes
2answers
307 views

How do you calculate if 2 lines are facing toward or away?

Given the 4 points describing 2 line segments, how do you calculate if line A is towards or away from line B? The 2 lines have a fixed length, and can be measured as distance from x1/y1 to x2/y2.
9
votes
6answers
2k views

How do I calculate distance from a point to a 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 ...
8
votes
1answer
650 views

How can I project a 3D point onto a 3D line?

Let's say I have a line defined by two points, A and B, both in the form (x, y, z). These points represent a line in 3D space. I also have a point P, defined in the same format, that isn't on the ...
8
votes
2answers
2k views

How do I determine if one polygon completely contains another?

I have 2 polygons. I know the vertex coordinates of both polygons. What's the best way to check if one is completely inside the other? For example, the algorithm should only recognize the black ...
8
votes
1answer
2k views

Am I going to regret using a color based collision detection system?

I'm just getting started build my first game with XNA (I'm experienced with C# but not games). I'm building a pretty simple top down 2d shooter. I read this tutorial on using a color based collision ...
8
votes
1answer
192 views

What are some ways to implement variable body shapes?

Games like Ryzom and the Sims allow players to have human bodies with different shapes: wide or thin, tall or short, big noses or small, etc. It seems to me that it'd be impractical to pre-generate ...
7
votes
2answers
1k views

Geometry System of Populous: The Beginning

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 - ...
7
votes
3answers
566 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 ...
7
votes
2answers
802 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 ...
7
votes
4answers
1k views

Implementing 2D CSG (for collision shapes)?

Are there any simple (or well documented) algorithms for basic CSG operations on 2D polygons? I'm looking for a way to 'add' a number of overlapping 2D collision shapes. These may be convex or ...
7
votes
1answer
291 views

Tessellation vs Geometry Shader

Correct me if I'm wrong, but both the Geometry Shader and the Tessellation Shader jobs are to generate vertices in the Graphic Pipeline. What I would like to know is how they are different and when ...
7
votes
3answers
570 views

How do I target a tank turret with an offset barrel?

I have a tank model consisting of multiple parts, a body, a turret and the barrel of the gun. The turret is offset from the body origin and can rotate around the Y axis(up). The barrel is connected to ...
7
votes
2answers
166 views

Intersect of vector and triangle side

I'm trying to create a triangular touch surface for iOS where the user can drag around a point inside this triangle. Using information from this page, it is easy to figure out if the dragged point is ...
7
votes
1answer
486 views

How can I determine the first visible tile in an isometric perspective?

I am trying to render the visible portion of a diamond-shaped isometric map. The "world" coordinate system is a 2D Cartesian system, with the coordinates increasing diagonally (in terms of the view ...
6
votes
2answers
572 views

Perspective in early pseudo-3d games

Please take a look at the screenshot below, from the old classic Space Harrier. My question regards the curved perspective on the chequerboard 'ground'. It's got a strangely curved geometry (I ...
6
votes
1answer
2k views

Moving a particle around an Archimedean spiral at a constant speed

I want to move a particle in a spiral at a constant speed. Note that that is not a constant angular speed. This is proving rather difficult, and I'll go through my method so far below. The spiral in ...
6
votes
3answers
3k 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 ...
6
votes
1answer
750 views

Procedural Geometry Generation

I have recently been looking into SceneKit for OS X and noticed that there are several factory methods to create geometric shapes such as: Box, Capsule, Cone, Cylinder, Plane, Pyramid, Sphere, Torus ...
6
votes
3answers
571 views

Transforming a primitive tetrahedron into a primitive icosahedron?

I've created a tetrahedron by creating a BoundingBox and building the faces of the tetrahedron within the bounding box as follows (see image as well): VertexPositionNormalTexture[] vertices = new ...
6
votes
2answers
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 = ...
6
votes
2answers
381 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 ...
6
votes
2answers
196 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 ...
5
votes
4answers
275 views

Would like some help in understanding rendering geometry vs textures

So I was just pondering whether it is more taxing on the GPU to render geometry or a texture. What I'm trying to see is whether there is a huge difference in rendering two scenes with the same setup: ...
5
votes
1answer
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 ...
5
votes
1answer
845 views

How to perform simple collision detection?

Imagine two squares sitting side by side, both level with the ground like so: A simple way to detect if one is hitting the other is to compare the location of each side. They are touching if all of ...
5
votes
1answer
136 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 ...
5
votes
1answer
7k 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?
5
votes
2answers
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 ...
5
votes
1answer
1k views

Creating similar effects of Geometry Wars in 2D only

I want to create a game with similar effects to that of "Geometry Wars"... for those who have never played the game, basically, massive amounts of 'bending' and 'warping' effects are done on the ...
5
votes
1answer
194 views

A* search in hexagonal grid with minimum turn radius

I need to run an A* search through a hexagonal grid. However, I have one nasty constraint: my vehicle can only turn so sharp. It has a specified minimum turn radius. I can't quite see how to translate ...