InPoly

From NPC for VCMP 0.4 Servers
Revision as of 07:50, 1 October 2024 by Habi (talk | contribs)
Jump to navigation Jump to search


Description:
Checks if a point is inside a polygon defined by multiple vertices.


Parameters:

(px, py, x1, y1, x2, y2, ...)

px, py: The coordinates of the point to be checked.
x1, y1: The coordinates of the first vertex of the polygon.
x2, y2: The coordinates of the second vertex of the polygon.
...: The coordinates of subsequent vertices of the polygon.


Return Values:
Returns `true` if the point is inside the polygon, otherwise returns `false`.


Example

InPoly.png
local inside = InPoly(3, 4, 0, 0, 6, 0, 6, 6, 0, 6);
if(inside)
    print("The point (3,4) is inside the polygon.");
else
    print("The point (3,4) is outside the polygon.");