示例#1
0
        public void Orient()
        {
            double[] p1 = new[] { 0.10000000000000001, 0.10000000000000001 };
            double[] p2 = new[] { 0.20000000000000001, 0.20000000000000004 };
            double[] p3 = new[] { 0.79999999999999993, 0.80000000000000004 };
            double[] p4 = new[] { 1.267650600228229e30, 1.2676506002282291e30 };

            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2DFast(p1, p2, p3) > 0.0);  // Wrong!
            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2DExact(p1, p2, p3) < 0.0);
            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2DSlow(p1, p2, p3) < 0.0);
            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2D(p1, p2, p3) < 0.0);

            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2DFast(p1, p2, p4) == 0.0); // Wrong!
            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2DExact(p1, p2, p4) < 0.0);
            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2DSlow(p1, p2, p4) < 0.0);
            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2D(p1, p2, p4) < 0.0);

            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2DFast(p2, p3, p4) == 0.0); // Wrong!
            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2DExact(p2, p3, p4) < 0.0);
            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2DSlow(p2, p3, p4) < 0.0);
            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2D(p2, p3, p4) < 0.0);

            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2DFast(p3, p1, p4) == 0.0); // Wrong!
            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2DExact(p3, p1, p4) > 0.0);
            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2DSlow(p3, p1, p4) > 0.0);
            NUnit.Framework.Assert.IsTrue(GeometricPredicatesManaged.Orient2D(p3, p1, p4) > 0.0);
        }
示例#2
0
        static double Orient2D_Checked_InOrder(double[] pa, double[] pb, double[] pc)
        {
            double fast  = GeometricPredicatesManaged.Orient2DFast(pa, pb, pc);
            double exact = GeometricPredicatesManaged.Orient2DExact(pa, pb, pc);
            double slow  = GeometricPredicatesManaged.Orient2DSlow(pa, pb, pc);
            double adapt = GeometricPredicatesManaged.Orient2D(pa, pb, pc);

            Assert.AreEqual(exact, slow);
            Assert.AreEqual(exact, adapt);

            // We don't expect these to be true, but it's nice to stop when they're not...
//            Assert.IsTrue(Math.Sign(fast) == Math.Sign(exact));
//            Assert.IsTrue(Math.Abs(fast - exact) < 1e-4);
            if (System.Math.Sign(fast) != System.Math.Sign(adapt))
            {
                Debug.Print("Fast: " + fast + " Adapt: " + adapt);
            }


            return(adapt);
        }