A* Pathfinding Project
4.3.2
The A* Pathfinding Project for Unity 3D

Utility functions for working with polygons, lines, and other vector math. More...
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.
Static Public Member Functions  
static Vector2  ClosestPointOnTriangle (Vector2 a, Vector2 b, Vector2 c, Vector2 p) 
Closest point on the triangle abc to the point p. More...  
static Vector3  ClosestPointOnTriangle (Vector3 a, Vector3 b, Vector3 c, Vector3 p) 
Closest point on the triangle abc to the point p. More...  
static Vector3  ClosestPointOnTriangleXZ (Vector3 a, Vector3 b, Vector3 c, Vector3 p) 
Closest point on the triangle abc to the point p when seen from above. More...  
static void  CompressMesh (List< Int3 > vertices, List< int > triangles, out Int3[] outVertices, out int[] outTriangles) 
Compress the mesh by removing duplicate vertices. More...  
static bool  ContainsPoint (Int2 a, Int2 b, Int2 c, Int2 p) 
Returns if the triangle ABC contains the point p. More...  
static bool  ContainsPoint (Vector2[] polyPoints, Vector2 p) 
Checks if p is inside the polygon. More...  
static bool  ContainsPointXZ (Vector3 a, Vector3 b, Vector3 c, Vector3 p) 
Returns if the triangle ABC contains the point p in XZ space. More...  
static bool  ContainsPointXZ (Int3 a, Int3 b, Int3 c, Int3 p) 
Returns if the triangle ABC contains the point p. More...  
static bool  ContainsPointXZ (Vector3[] polyPoints, Vector3 p) 
Checks if p is inside the polygon (XZ space). More...  
static Vector3 []  ConvexHullXZ (Vector3[] points) 
Calculates convex hull in XZ space for the points. More...  
static int  SampleYCoordinateInTriangle (Int3 p1, Int3 p2, Int3 p3, Int3 p) 
Sample Y coordinate of the triangle (p1, p2, p3) at the point p in XZ space. More...  
static void  Subdivide (List< Vector3 > points, List< Vector3 > result, int subSegments) 
Divides each segment in the list into subSegments segments and fills the result list with the new points. More...  
static void  TraceContours (Dictionary< int, int > outline, HashSet< int > hasInEdge, System.Action< List< int >, bool > results) 
Given a set of edges between vertices, follows those edges and returns them as chains and cycles. More...  
Static Private Attributes  
static readonly Dictionary< Int3, int >  cached_Int3_int_dict = new Dictionary<Int3, int>() 
Cached dictionary to avoid excessive allocations. More...  

static 
Closest point on the triangle abc to the point p.

static 
Closest point on the triangle abc to the point p.

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

static 
Compress the mesh by removing duplicate vertices.
vertices  Vertices of the input mesh 
triangles  Triangles of the input mesh 
outVertices  Vertices of the output mesh. 
outTriangles  Triangles of the output mesh. 
Vertices that differ by only 1 along the y coordinate will also be merged together.
Returns if the triangle ABC contains the point p.
The triangle vertices are assumed to be laid out in clockwise order.

static 
Checks if p is inside the polygon.

static 
Returns if the triangle ABC contains the point p in XZ space.
The triangle vertices are assumed to be laid out in clockwise order.
Returns if the triangle ABC contains the point p.
The triangle vertices are assumed to be laid out in clockwise order.

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

static 
Calculates convex hull in XZ space for the points.
Implemented using the very simple Gift Wrapping Algorithm which has a complexity of O(nh) where n is the number of points and h is the number of points on the hull, so it is in the worst case quadratic.
Sample Y coordinate of the triangle (p1, p2, p3) at the point p in XZ space.
The y coordinate of p is ignored.

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

static 
Given a set of edges between vertices, follows those edges and returns them as chains and cycles.
outline  outline[a] = b if there is an edge from a to b. 
hasInEdge  hasInEdge should contain b if outline[a] = b for any key a. 
results  Will be called once for each contour with the contour as a parameter as well as a boolean indicating if the contour is a cycle or a chain (see image). 
Cached dictionary to avoid excessive allocations.