# Falling polygons: meshing vs. stacking - analytic solution needed

1. Nov 3, 2013

### SLanghi

Falling polygons: meshing vs. stacking -- analytic solution needed

I'm a game developer and not a mathematics specialist, so I'm not 100% sure if this question is correctly categorized.

My problem is as follows.

I'm building a game that's similar to Tetris, but in 3D instead of 2D. Rather than arranging falling tetriminos to form lines within a grid, the player arranges falling tangram pieces to form squares within a square basin.

All of the tangram pieces occupy even fractions of a square (1/4, 1/8, 1/2). Furthermore, when a piece lands, each of its vertices aligns with one of the following: the corners of the basin, the midpoints of the basin's sides, or the central midpoint of the basin.

As the player guides the falling pieces, there will be cases in which a piece nestles just inside the vacancy formed by other, adjacent pieces. I need a collision-detection logic that can allow for these situations where the descending object "just fits" into a hole having the exact shape and size of the piece.

The polygonal collision engine I'm using (Unity) is exhibiting problematic behavior. Even when the tangrams' vertices are aligned exactly to the key points mentioned above, the physics-based polygonal collision logic registers an overlap between a falling piece and one of the pieces bordering the hole into which it's falling. As a result, the falling piece stacks on top of the other pieces, though it appears to the naked eye that the falling piece should have continued into the hole.

I'd like to use an analytic solution that can tell me whether a space within the basin having a particular shape at a particular location is occupied or vacant, given full prior knowledge of the tangrams already residing with the basin. I have very few ideas about where to start with this. If anyone can provide a solution method, or even point me toward the correct mathematical topic, I'll greatly appreciate it.

2. Nov 4, 2013

### Staff: Mentor

Hmm, certainly not differential geometry. Either general math or programming.

If I understand your problem correctly, the polygon positions are discrete. Why don't you just make a grid and check if one element of it is occupied?