# Class Polygon

Public

Utility functions for working with polygons, lines, and other vector math.

All functions which accepts Vector3s but work in 2D space uses the XZ space if nothing else is said.

### Version

A lot of functions in this class have been moved to the VectorMath class the names have changed slightly and everything now consistently assumes a left handed coordinate system now instead of sometimes using a left handed one and sometimes using a right handed one. This is why the 'Left' methods redirect to methods named 'Right'. The functionality is exactly the same.

## Public Static Methods

ClosestPointOnTriangle (a, b, c, p)

Closest point on the triangle abc to the point p.

Public Static
ClosestPointOnTriangle (a, b, c, p)

Closest point on the triangle abc to the point p.

Public Static
ClosestPointOnTriangleXZ (a, b, c, p)

Closest point on the triangle abc to the point p when seen from above.

Public Static
CompressMesh (vertices, triangles, outVertices, outTriangles)

Compress the mesh by removing duplicate vertices.

Public Static
ContainsPoint (polyPoints, p)

Checks if p is inside the polygon.

Public Static
ContainsPoint (polyPoints, p)

Checks if p is inside the polygon (XZ space)

Public Static
ContainsPoint (a, b, c, p)

Returns if the triangle ABC contains the point p.

Public Static
ContainsPoint (a, b, c, p)

Returns if the triangle ABC contains the point p.

Public Static
ContainsPoint (a, b, c, p)

Returns if the triangle ABC contains the point p in XZ space.

Public Static
ContainsPointXZ (polyPoints, p)

Checks if p is inside the polygon (XZ space).

Public Static
ContainsPointXZ (a, b, c, p)

Returns if the triangle ABC contains the point p.

Public Static
ContainsPointXZ (a, b, c, p)

Returns if the triangle ABC contains the point p in XZ space.

Public Static
ConvexHullXZ (points)

Calculates convex hull in XZ space for the points.

Public Static
IntersectsUnclamped (a, b, a2, b2)

Returns if the line segment a2 - b2 intersects the infinite line a - b.

Public Static
SampleYCoordinateInTriangle (p1, p2, p3, p)

Sample Y coordinate of the triangle (p1, p2, p3) at the point p in XZ space.

Public Static
Subdivide (points, result, subSegments)

Divides each segment in the list into subSegments segments and fills the result list with the new points.

Public Static
TraceContours (outline, hasInEdge, results)

Given a set of edges between vertices, follows those edges and returns them as chains and cycles.

Public Static
TriangleArea (a, b, c)

Signed area of a triangle in the XZ plane multiplied by 2.

Public Static
TriangleArea (a, b, c)

Signed area of a triangle in the XZ plane multiplied by 2.

Public Static
TriangleArea2 (a, b, c)

Signed area of a triangle in the XZ plane multiplied by 2.

Public Static
TriangleArea2 (a, b, c)

Signed area of a triangle in the XZ plane multiplied by 2.

Public Static

## Private/Protected Members

cached_Int3_int_dict

Cached dictionary to avoid excessive allocations.

## Deprecated Members

ClosestPointOnTriangle (triangle, point)

Returns the closest point on the triangle.

Public Static
ConvexHull (points)

Calculates convex hull in XZ space for the points.

Public Static
DistanceSegmentSegment3D (s1, e1, s2, e2)

Get the 3D minimum distance between 2 segments Input: two 3D line segments S1 and S2.

Public Static
IntersectionFactor (start1, end1, start2, end2)

Returns the intersection factor for line 1 with line 2.

Public Static
IntersectionFactor (start1, end1, start2, end2, factor1, factor2)

Returns the intersection factors for line 1 and line 2.

Public Static
IntersectionFactor (start1, end1, start2, end2, factor1, factor2)

Returns the intersection factors for line 1 and line 2.

Public Static
IntersectionFactorRay (start1, end1, start2, end2)

Returns the intersection factor for line 1 with ray 2.

Public Static
IntersectionFactorRaySegment (start1, end1, start2, end2)

Returns if the ray (start1, end1) intersects the segment (start2, end2).

Public Static
IntersectionPoint (start1, end1, start2, end2)

Returns the intersection point between the two lines.

Public Static
IntersectionPoint (start1, end1, start2, end2)

Returns the intersection point between the two lines.

Public Static
IntersectionPoint (start1, end1, start2, end2, intersects)

Returns the intersection point between the two lines.

Public Static
IntersectionPoint (start1, end1, start2, end2, intersects)

Returns the intersection point between the two lines.

Public Static
IntersectionPointOptimized (start1, dir1, start2, dir2)

Intersection point between two infinite lines.

Public Static
IntersectionPointOptimized (start1, dir1, start2, dir2, intersects)

Intersection point between two infinite lines.

Public Static
Intersects (start1, end1, start2, end2)

Returns if the line segment a2 - b2 intersects the line segment a - b.

Public Static
Intersects (start1, end1, start2, end2)

Returns if the two line segments intersects.

Public Static
Intersects (start1, end1, start2, end2)

Returns if the line segment a2 - b2 intersects the line segment a - b.

Public Static
IsClockwise (a, b, c)

Returns if the points a in a clockwise order.

Public Static
IsClockwise (a, b, c)

Returns if the points a in a clockwise order.

Public Static
IsClockwiseMargin (a, b, c)

Returns true if the points a in a clockwise order or if they are colinear.

Public Static
IsClockwiseMargin (a, b, c)

Returns if the points a in a clockwise order.

Public Static
IsClockwiseMargin (a, b, c)

Returns true if the points a in a clockwise order or if they are colinear.

Public Static
IsColinear (a, b, c)

Returns if the points are colinear (lie on a straight line)

Public Static
IsColinear (a, b, c)

Returns if the points are colinear (lie on a straight line)

Public Static
IsColinearAlmost (a, b, c)

Returns if the points are colinear (lie on a straight line)

Public Static
Left (a, b, p)

Returns if p lies on the left side of the line a - b.

Public Static
Left (a, b, p)

Returns if p lies on the left side of the line a - b.

Public Static
Left (a, b, p)

Returns if p lies on the left side of the line a - b.

Public Static
Left (a, b, p)

Returns if p lies on the left side of the line a - b.

Public Static
LeftNotColinear (a, b, p)

Returns if p lies on the left side of the line a - b.

Public Static
LeftNotColinear (a, b, p)

Returns if p lies on the left side of the line a - b.

Public Static
LineIntersectsBounds (bounds, a, b)

Does the line segment intersect the bounding box.

Public Static
SegmentIntersectionPoint (start1, end1, start2, end2, intersects)

Returns the intersection point between the two line segments in XZ space.

Public Static