public static List <Vector3> BuildHull(PointsArray3 points) { QuickHull qHull = new QuickHull(points); qHull.BuildHull(); return(qHull.GetTriangles()); }
public static GeoPointsArray3 BuildConvexHull(GeoPointsArray3 points) { points.Distinct(); GeoPlane plane = new GeoPlane(Vector3.zero, 0); if (IsOnSamePlane(points, ref plane)) { GeoPointsArray2 point2 = new GeoPointsArray2(GeoPlaneUtils.PlaneTransformLocal(points.mPointArray, plane)); point2 = BuildConvexHull(point2); return(new GeoPointsArray3(GeoPlaneUtils.PlaneTransformGlobal(point2.mPointArray, plane))); } else { return(new GeoPointsArray3(QuickHull.BuildHull(points))); } }
public static List <Vector3> CalculateConvexHull(List <Vector3> vertices, bool use2d, int ignore = 1) { List <Vector3> temp = new List <Vector3>(); if (use2d) { int x = 0; int y = 1; if (ignore == 0) { x = 1; y = 2; } else if (ignore == 1) { x = 0; y = 2; } else { x = 0; y = 1; } List <Vector2> temp2 = new List <Vector2>(); foreach (Vector3 v in vertices) { temp2.Add(new Vector2(v[x], v[y])); } temp2 = JarvisConvex.BuildHull(temp2); GeoPolygonUtils.ReverseIfCW(ref temp2); foreach (Vector2 v in temp2) { temp.Add(vertices.Find((Vector3 v3) => { return(v3[x] == v[0] && v3[y] == v[1]); })); } } else { temp = QuickHull.BuildHull(vertices); } return(temp); }