Created
January 13, 2016 15:33
-
-
Save SirGordon/6ae07d317f5406d503d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function isPointInPolygon(point:Vector3D, polygon:Vector.<Vector3D>):Boolean { | |
var i:int, j:int, nvert:int = polygon.length; | |
var result:Boolean = false; | |
for (i = 0, j = nvert - 1; i < nvert; j = i++) { | |
if (((polygon[i].z) >= point.z != (polygon[j].z >= point.z)) && | |
(point.x <= (polygon[j].x - polygon[i].x) * (point.z - polygon[i].z) / (polygon[j].z - polygon[i].z) + polygon[i].x)) | |
result = !result; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment