public static void Swap(ref SortedVertex v1, ref SortedVertex v2)
        {
            var temp = v1;

            v1 = v2;
            v2 = temp;
        }
        private static Triangle CreateTriangle(SortedVertex v1, SortedVertex v2, SortedVertex v3)
        {
            FixWindingOrder(ref v1, ref v2, v3);
            var triangle = new Triangle(v1.InitialIndex, v2.InitialIndex, v3.InitialIndex);

            return(triangle);
        }
        private static void FixWindingOrder(ref SortedVertex edgeV1, ref SortedVertex edgeV2, SortedVertex v1)
        {
            var crossProduct = TriangulationHelper.CrossProduct(edgeV2.Vertex - edgeV1.Vertex, v1.Vertex - edgeV2.Vertex);

            if (crossProduct > 0)
            {
                TriangulationHelper.Swap(ref edgeV1, ref edgeV2);
            }
        }
        private static void AddTriangle(SortedVertex v1, SortedVertex v2, SortedVertex v3, ISet <Triangle> existingTriangles,
                                        IEnumerable <IEnumerable <int> > holeVertices)
        {
            var triangle = CreateTriangle(v1, v2, v3);

            if (triangle != null)
            {
                AddTriangleIfNeeded(existingTriangles, triangle, holeVertices);
            }
        }
 private static void AddQuad(SortedVertex v1, SortedVertex v2, SortedVertex v3, SortedVertex v4,
                             ISet <Triangle> existingTriangles, IReadOnlyCollection <IEnumerable <int> > holeVertices)
 {
     AddTriangle(v1, v2, v3, existingTriangles, holeVertices);
     AddTriangle(v2, v1, v4, existingTriangles, holeVertices);
 }