C4 Engine
C4 Engine API Documentation


Defined in:  C4Computation.h
Returns a value indicating whether a point lies within the interior of a convex polygon, lies on its boundary, or lies outside the polygon.

int32 PointInConvexPolygon(const Point3D& p, int32 vertexCount, const Point3D *vertex, const Vector3D& normal);

p The point to test.
vertexCount The number of vertices defining the boundary of the polygon. This must be at least 3.
vertex An array containing the vertices of the polygon, wound in counterclockwise order.
normal The normal direction of the polygon.
The PointInConvexPolygon function determines the location of the point given by the p parameter with respect to the polygon specified by the vertexCount and vertex parameters. The return value is one of the following constants.
kPolygonInterior The point lies in the interior of the polygon.
kPolygonBoundary The point lies on or very near the boundary of the polygon.
kPolygonExterior The point lies outside the polygon.
The vertex parameter should point to an array of Point3D objects of size given by the vertexCount parameter. These vertices should be wound in counterclockwise order about the normal direction specified by the normal parameter. The polygon must be convex and must lie in a plane that is perpendicular to the normal direction. If these requirements are not satisfied, then the result is undefined.
See Also