I've been using an algorithm (http://wiki.unity3d.com/index.php/PolyContainsPoint) to tell me if a point is inside a polygon... in fact a few variants (here and here) but they all come back the same. Shapes with (0,0) vertices fail.
Here's the function:
private bool IsPointInPolygon(Vector2[] polyPoints, Vector2 p) { int j = polyPoints.Length-1; bool inside = false; for (int i = 0; i < polyPoints.Length; j = i++) { if ( ((polyPoints[i].y <= p.y && p.y < polyPoints[j].y) || (polyPoints[j].y <= p.y && p.y < polyPoints[i].y)) && (p.x < (polyPoints[j].x - polyPoints[i].x) * (p.y - polyPoints[i].y) / (polyPoints[j].y - polyPoints[i].y) + polyPoints[i].x)) inside = !inside; } return inside; } And here's the testing output for a number of 'cloned' squares being translated around the original square (original shown in black in the diagram) - Notice all the squares with the 0,0 fail. Why is this? I don't really know what the algorithm is doing but have tried a few with exactly the same result..
Vector origin (0.0, 0.0) to Vector destination (1.0, 0.0) distance: (1.0, 0.0) New Shape 1 0 New Shape 2 0 New Shape 2 1 New Shape 1 1 PASS Vector origin (0.0, 0.0) to Vector destination (1.0, 1.0) distance: (1.0, 1.0) New Shape 1 1 New Shape 2 1 New Shape 2 2 New Shape 1 2 PASS Vector origin (0.0, 0.0) to Vector destination (0.0, 1.0) distance: (0.0, 1.0) New Shape 0 1 New Shape 1 1 New Shape 1 2 New Shape 0 2 PASS Vector origin (1.0, 0.0) to Vector destination (0.0, 0.0) distance: (-1.0, 0.0) New Shape -1 0 New Shape 0 0 New Shape 0 1 New Shape -1 1 FAIL Vector origin (1.0, 0.0) to Vector destination (1.0, 1.0) distance: (0.0, 1.0) New Shape 0 1 New Shape 1 1 New Shape 1 2 New Shape 0 2 PASS Vector origin (1.0, 0.0) to Vector destination (0.0, 1.0) distance: (-1.0, 1.0) New Shape -1 1 New Shape 0 1 New Shape 0 2 New Shape -1 2 PASS Vector origin (1.0, 1.0) to Vector destination (0.0, 0.0) distance: (-1.0, -1.0) New Shape -1 -1 New Shape 0 -1 New Shape 0 0 New Shape -1 0 FAIL Vector origin (1.0, 1.0) to Vector destination (1.0, 0.0) distance: (0.0, -1.0) New Shape 0 -1 New Shape 1 -1 New Shape 1 0 New Shape 0 0 FAIL Vector origin (1.0, 1.0) to Vector destination (0.0, 1.0) distance: (-1.0, 0.0) New Shape -1 0 New Shape 0 0 New Shape 0 1 New Shape -1 1 FAIL Vector origin (0.0, 1.0) to Vector destination (0.0, 0.0) distance: (0.0, -1.0) New Shape 0 -1 New Shape 1 -1 New Shape 1 0 New Shape 0 0 FAIL Vector origin (0.0, 1.0) to Vector destination (1.0, 0.0) distance: (1.0, -1.0) New Shape 1 -1 New Shape 2 -1 New Shape 2 0 New Shape 1 0 PASS Vector origin (0.0, 1.0) to Vector destination (1.0, 1.0) distance: (1.0, 0.0) New Shape 1 0 New Shape 2 0 New Shape 2 1 New Shape 1 1 PASS 