static int Main(string[] args) { Convex_hull t = new Convex_hull("points.txt"); List <Point> tmp1 = new List <Point>(); List <Point> tmp2 = new List <Point>(); List <Point> tmp3 = new List <Point>(); List <Point> tmp4 = new List <Point>(); List <Tuple <int, int> > tmp0 = new List <Tuple <int, int> >(); List <Line> visual = new List <Line>(); tmp1 = t.Grehem(); tmp2 = t.Kirkpatrick(); tmp3 = t.Edwin_Jarvis(visual); tmp4 = t.Quickhull(visual); List <List <Tuple <Line, int> > > tmp = new List <List <Tuple <Line, int> > >(); tmp = t.Voronoi(); tmp0 = t.Delaunay(); //Console.ReadKey(); Tuple <List <Point>, List <Point> > r = t.bucket_sort(t); List <Tuple <Line, int> > t4 = new List <Tuple <Line, int> >(); t4 = t.Voronoi_cell(4, visual); //Console.ReadKey(); return(0); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.R)) { t = new Convex_hull.Convex_hull("tmpPoints.txt"); for (int i = 0; i < t.Size; ++i) { float x0 = (float)t.points[i].x - 7.5f; float y0 = (float)t.points[i].y - 5f; Instantiate(n0, new Vector3(x0 * 10, y0 * 10), Quaternion.identity); } } if (Input.GetKeyDown(KeyCode.G)) { int nn = GameObject.Find("Nodes").transform.childCount; for (int i = 0; i < nn; ++i) { Destroy(GameObject.Find("Nodes").transform.GetChild(i)); } List <Point> tmp = new List <Point>(); for (int i = 0; i < count; ++i) { float x0 = Random.Range(-7.5f, 7.5f); float y0 = Random.Range(-5f, 5f); Instantiate(n0, new Vector3(x0 * 10, y0 * 10), Quaternion.identity); tmp.Add(new Point(i, x0 + 7.5f, y0 + 5)); } t = new Convex_hull.Convex_hull(count, tmp); } if (Input.GetKeyDown(KeyCode.V)) { System.DateTime tt = System.DateTime.Now; List <List <System.Tuple <Line, int> > > toVis = t.Voronoi(); for (int pn = 0; pn < toVis.Count; ++pn) { //for (int i = 0; i < toVis[pn].Count; ++i) //{ // int j = 0; // for (int jj = 0; jj < pn; ++jj) // j += toVis[jj].Count; // StartCoroutine(toVisSegm(true, j + i, ((float)toVis[pn][i].Item1.a.x - 7.5f) * 10f, ((float)toVis[pn][i].Item1.a.y - 5) * 10f, ((float)toVis[pn][i].Item1.b.x - 7.5f) * 10f, ((float)toVis[pn][i].Item1.b.y - 5) * 10f)); //} StartCoroutine(toVisAll(pn * 5 / (float)count, "n" + (pn + 1).ToString(), toVis[pn])); } Debug.Log((System.DateTime.Now - tt).ToString()); } if (Input.GetKeyDown(KeyCode.H)) { Destroy(lr); List <Point> visual = t.Grehem(); StartCoroutine(toVisHull(0, visual, Color.gray)); } if (Input.GetKeyDown(KeyCode.K)) { Destroy(lr); List <Point> toVis = t.Kirkpatrick(); StartCoroutine(toVisHull(0, toVis, Color.magenta)); } if (Input.GetKeyDown(KeyCode.E)) { Destroy(lr); List <Line> toVis = new List <Line>(); List <Point> visual = t.Edwin_Jarvis(toVis); StartCoroutine(toVisHull(0, visual, Color.red)); } if (Input.GetKeyDown(KeyCode.Q)) { Destroy(lr); List <Line> toVis = new List <Line>(); List <Point> visual = t.Quickhull(toVis); StartCoroutine(toVisHull(0, visual, Color.blue)); } if (Input.GetKeyDown(KeyCode.D)) { //Destroy(lr); t.max_x += 100; t.max_y += 100; t.min_x -= 100; t.min_y -= 100; List <System.Tuple <int, int> > toVis = t.Delaunay(); for (int i = 0; i < toVis.Count; ++i) { GameObject p = GameObject.CreatePrimitive(PrimitiveType.Cylinder); p.transform.position = new Vector3(0, 0, 100); StartCoroutine(toVisSegmN(p, i * 5 / (float)toVis.Count, ((float)t.points[toVis[i].Item1].x - 7.5f) * 10f, ((float)t.points[toVis[i].Item1].y - 5f) * 10f, ((float)t.points[toVis[i].Item2].x - 7.5f) * 10f, ((float)t.points[toVis[i].Item2].y - 5f) * 10f)); } } }