public static List <Vector2> BuildHull(List <Vector2> points, float scale = 10) { JarvisConvex jarvis = new JarvisConvex(); foreach (Vector2 p in points) { jarvis.AddPoint(p * scale); } return(jarvis.Calculate(scale)); }
public static List <Vector2> BuildHullIndex(List <Vector2> points, out List <int> resultIndex, float scale = 10) { JarvisConvex jarvis = new JarvisConvex(); foreach (Vector2 p in points) { jarvis.AddPoint(p * scale); } var ps = jarvis.Calculate(scale); resultIndex = jarvis.mResultIndex; return(ps); }
public static void VoronoiGraphScatter(List <Vector2> datas) { // 计算凸包 List <Vector2> jarvis = JarvisConvex.BuildHull(datas); // 逆时针 // 剔除凸包上的点 List <Vector2> leftPoints = Remove(datas, jarvis); // 寻找左半凸包 List <Vector2> leftJarvis = LeftJarvis(jarvis); // 扫描线分区 List <RegionPoints> regions = GroupRegions(ref leftPoints, leftJarvis); // 剩余的点 连成不相交的折线,合并到最后一个折线里去 if (leftPoints.Count > 0) { } // 查找折线 FindPolyline(jarvis, regions); }
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); }
public static GeoPointsArray2 BuildConvexHull(GeoPointsArray2 points) { points.Distinct(); return(new GeoPointsArray2(JarvisConvex.BuildHull(points.mPointArray))); }