public void DelaunayTrianglesTest([ValueSource(nameof(nums))] int num) { var sw = Stopwatch.StartNew(); var bf = new BistellarFlip2D(num); sw.Stop(); UnityEngine.Debug.Log(sw.Elapsed); foreach (var n in bf.Nodes) { var t = n.triangle; var c = n.triangle.GetCircumscribledCircle(); var ab = new Segment(t.a, t.b); var bc = new Segment(t.b, t.c); var ca = new Segment(t.c, t.a); var pair_ab = n.neighbor.Find(_n => _n.Contains(ab)); var pair_bc = n.neighbor.Find(_n => _n.Contains(bc)); var pair_ca = n.neighbor.Find(_n => _n.Contains(ca)); if (pair_ab != null) { Assert.IsFalse(c.Contains(pair_ab.triangle.RemainingPoint(ab))); } if (pair_bc != null) { Assert.IsFalse(c.Contains(pair_bc.triangle.RemainingPoint(bc))); } if (pair_ca != null) { Assert.IsFalse(c.Contains(pair_ca.triangle.RemainingPoint(ca))); } } }
void Start() { var bf = new BistellarFlip2D(numPoint); var nodes = bf.Nodes.ToArray(); int count = 0; voronoi = new VoronoiGraph2D(nodes); foreach (var n in voronoi.nodes) { var o = n.Value.Meshilify(); if (o.vertices.Any(v => v.x < min || v.x > max || v.y < min || v.y > max)) { continue; } var g = new GameObject(count.ToString()); var f = g.AddComponent <MeshFilter>(); var r = g.AddComponent <MeshRenderer>(); var m = new Material(mat); r.sharedMaterial = m; f.mesh = o; count++; } }