| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2894,10 +2894,17 @@ public boolean isClosed() { | |||
| 2894 | 2894 | // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html | |
| 2895 | 2895 | public boolean contains(float x, float y) { | |
| 2896 | 2896 | if (family == PATH) { | |
| 2897 | + // apply the inverse transformation matrix to the point coordinates | ||
| 2898 | + PMatrix inverseCoords = matrix.get(); | ||
| 2899 | + inverseCoords.invert(); // maybe cache this? | ||
| 2900 | + inverseCoords.invert(); // maybe cache this? | ||
| 2901 | + PVector p = new PVector(); | ||
| 2902 | + inverseCoords.mult(new PVector(x,y),p); | ||
| 2903 | + | ||
| 2897 | 2904 | boolean c = false; | |
| 2898 | 2905 | for (int i = 0, j = vertexCount-1; i < vertexCount; j = i++) { | |
| 2899 | - if (((vertices[i][Y] > y) != (vertices[j][Y] > y)) && | ||
| 2900 | - (x < | ||
| 2906 | + if (((vertices[i][Y] > p.y) != (vertices[j][Y] > p.y)) && | ||
| 2907 | + (p.x < | ||
| 2901 | 2908 | (vertices[j][X]-vertices[i][X]) * | |
| 2902 | 2909 | (y-vertices[i][Y]) / | |
| 2903 | 2910 | (vertices[j][1]-vertices[i][Y]) + | |
| Back | FazBrowse Home | New Git URL |
0 commit comments