-
-
Save painkkiller/d9bba078760aeea72084 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
у меня Vector3D, в котором y игнорируется
ты можешь использовать Point
и вместо z везде используй y
у меня просто x и z используются
т.к. y вверх а полигон всегда лежит на земле, ровно как и точка (y==0)