/// <summary> /// If this edge is the edge(v0, v1) /// </summary> /// <param name="v0"></param> /// <param name="v1"></param> /// <returns>True if this edge's vertices are v0 & v1</returns> public bool EqualEdge(DualSite v0, DualSite v1) { if ((Vertex0 == v0 && Vertex1 == v1) || (Vertex1 == v0 && Vertex0 == v1)) { return(true); } else { return(false); } }
/// <summary> /// Set the neighboring triangular faces (convex hull) /// </summary> /// <param name="neighbor">the neighboring triangular face</param> /// <param name="v1">a vertex of the shared edge</param> /// <param name="v2">the other vertex</param> public void SetNeighbor(TriangularFace neighbor, DualSite v1, DualSite v2) { Edge edge1 = this.GetEdge(v1, v2); if (edge1 != null) { edge1.SetFace(neighbor); Edge edge2 = neighbor.GetEdge(v1, v2); edge2.SetFace(this); } }
/// <summary> /// If v is outside of the face (refer to normal vector) /// </summary> /// <param name="v">he vertex to be tested</param> /// <returns>True if v is outside of the face (refer to normal vector) </returns> public bool VOutFace(DualSite v) { if (Vector3D.DotProduct(Normal, v.Coordinate - Vertex0.Coordinate) > Eps) { return(true); } else { return(false); } }
/// <summary> /// Repersents a triangular face in 3-D space /// </summary> /// <param name="v0">vertices in counter-clockwise order</param> /// <param name="v1"></param> /// <param name="v2"></param> public TriangularFace(DualSite v0, DualSite v1, DualSite v2) { this.Vertex0 = v0; this.Vertex1 = v1; this.Vertex2 = v2; this.Edge0 = new Edge(v0, v1); this.Edge1 = new Edge(v1, v2); this.Edge2 = new Edge(v2, v0); this.Edge0.NextEdge = this.Edge1; this.Edge1.NextEdge = this.Edge2; this.Edge2.NextEdge = this.Edge0; this.Normal = Vector3D.CrossProduct(v1.Coordinate - v0.Coordinate, v2.Coordinate - v0.Coordinate); this.Normal.Normalize(); this.DualPoint = new Vector(); this.Valid = true; }
/// <summary> /// Get the edge of this face with vertices v1, v2 /// </summary> /// <param name="v1">a vertex of the edge</param> /// <param name="v2">the other vertex</param> /// <returns>null if it cannot be found</returns> public Edge GetEdge(DualSite v1, DualSite v2) { if (Edge0.EqualEdge(v1, v2)) { return(Edge0); } else if (Edge1.EqualEdge(v1, v2)) { return(Edge1); } else if (Edge2.EqualEdge(v1, v2)) { return(Edge2); } else { return(null); } }
public Edge(DualSite v0, DualSite v1) { this.Vertex0 = v0; this.Vertex1 = v1; }