Exemple #1
0
        public void FindContainingTriangleTest()
        {
            var ret = T.FindContainingTriangle(new Vector2(1, 0.5f));

            Assert.AreEqual(t1, ret);
            ret = T.FindContainingTriangle(new Vector2(1, -0.5f));
            Assert.AreEqual(t2, ret);
            ret = T.FindContainingTriangle(new Vector2(-5, 0));
            Assert.IsNull(ret);
        }
Exemple #2
0
        /// <summary>
        /// Adds a vertex at the given position to the Delaunay triangulation.
        /// Legalizes relevant edges in order to maintain Delaunay condition.
        /// </summary>
        /// <param name="T"></param>
        /// <param name="a_vertex"></param>
        /// <returns></returns>
        public static void AddVertex(Triangulation T, Vector2 a_vertex)
        {
            // find triangle that contains X
            var triangle = T.FindContainingTriangle(a_vertex);

            T.AddVertex(a_vertex);

            // Flip if needed
            LegalizeEdge(T, a_vertex, triangle.E0);
            LegalizeEdge(T, a_vertex, triangle.E1);
            LegalizeEdge(T, a_vertex, triangle.E2);
        }