public Tetrahedron(PVector p1, PVector p2, PVector p3, PVector p4) { Vertices = new PVector[4]; P1 = p1; Vertices[0] = p1; P2 = p2; Vertices[1] = p2; P3 = p3; Vertices[2] = p3; P4 = p4; Vertices[3] = p4; getCenterCircumcircle(); }
/// <summary> /// Calculate Delaunay Triangulation /// </summary> /// <param name="pVectorList">AllPoints</param> /// <returns>Tetrahedrone List</returns> private List <Tetrahedron> GetTetraList(List <PVector> pVectorList) { List <Tetrahedron> tetraList = new List <Tetrahedron>(); tetraList.Add(this.FirstTetra); List <Tetrahedron> tmpTList = new List <Tetrahedron>(); List <Tetrahedron> newTList = new List <Tetrahedron>(); List <Tetrahedron> removeTList = new List <Tetrahedron>(); foreach (var point in pVectorList) { tmpTList.Clear(); newTList.Clear(); removeTList.Clear(); foreach (var t in tetraList) { if ((t.O != null) && (t.R > Common.GetDist(point, t.O))) { tmpTList.Add(t); } } foreach (var t1 in tmpTList) { tetraList.Remove(t1); PVector v1 = t1.P1; PVector v2 = t1.P2; PVector v3 = t1.P3; PVector v4 = t1.P4; newTList.Add(new Tetrahedron(v1, v2, v3, point)); newTList.Add(new Tetrahedron(v1, v2, v4, point)); newTList.Add(new Tetrahedron(v1, v3, v4, point)); newTList.Add(new Tetrahedron(v2, v3, v4, point)); } bool[] isRedundancy = new bool[newTList.Count]; for (int i = 0; i < newTList.Count - 1; i++) { for (int j = i + 1; j < newTList.Count; j++) { if (newTList[i].Equal(newTList[j])) { isRedundancy[i] = isRedundancy[j] = true; } } } for (int i = 0; i < newTList.Count; i++) { if (!isRedundancy[i]) { tetraList.Add(newTList[i]); } } } PVector[] outer = new PVector[] { this.FirstTetra.P1, this.FirstTetra.P2, this.FirstTetra.P3, this.FirstTetra.P4 }; bool isOuter = false; var count = 0; for (int i = tetraList.Count - 1; i >= 0; i--) { isOuter = false; foreach (var t4Point in tetraList[i].Vertices) { foreach (var outerPoint in outer) { if (t4Point.X == outerPoint.X && t4Point.Y == outerPoint.Y && t4Point.Z == outerPoint.Z) { isOuter = true; } } } if (isOuter) { tetraList.RemoveAt(i); count++; Console.WriteLine(count); } } return(tetraList); }
public PVector Sub(PVector src) { PVector dst = new PVector(this.X - src.X, this.Y - src.Y, this.Z - src.Z); return(dst); }
public float Dot(PVector src) { return(X * (src.X) + Y * src.Y + Z * src.Z); }