/// <summary> /// Checks if the computed value for isInCircle is correct, using /// double-double precision arithmetic. /// </summary> /// <param name="a">A vertex of the triangle</param> /// <param name="b">A vertex of the triangle</param> /// <param name="c">A vertex of the triangle</param> /// <param name="p">The point to test</param> private static void CheckRobustInCircle(Coordinate a, Coordinate b, Coordinate c, Coordinate p) { bool nonRobustInCircle = IsInCircle(a, b, c, p); bool isInCircleDD = TriPredicate.IsInCircleDD(a, b, c, p); bool isInCircleCC = TriPredicate.IsInCircleCC(a, b, c, p); var circumCentre = Triangle.Circumcentre(a, b, c); Console.WriteLine("p radius diff a = " + Math.Abs(p.Distance(circumCentre) - a.Distance(circumCentre)) / a.Distance(circumCentre)); if (nonRobustInCircle != isInCircleDD || nonRobustInCircle != isInCircleCC) { Console.WriteLine("inCircle robustness failure (double result = " + nonRobustInCircle + ", DD result = " + isInCircleDD + ", CC result = " + isInCircleCC + ")"); Console.WriteLine(WKTWriter.ToLineString(new CoordinateArraySequence( new Coordinate[] { a, b, c, p }))); Console.WriteLine("Circumcentre = " + WKTWriter.ToPoint(circumCentre) + " radius = " + a.Distance(circumCentre)); Console.WriteLine("p radius diff a = " + Math.Abs(p.Distance(circumCentre) / a.Distance(circumCentre) - 1)); Console.WriteLine("p radius diff b = " + Math.Abs(p.Distance(circumCentre) / b.Distance(circumCentre) - 1)); Console.WriteLine("p radius diff c = " + Math.Abs(p.Distance(circumCentre) / c.Distance(circumCentre) - 1)); Console.WriteLine(); } }
public double runDDSelf2(int nIter) { Stopwatch sw = new Stopwatch(); sw.Start(); for (int i = 0; i < nIter; i++) { TriPredicate.IsInCircleDD3(_pa, _pb, _pc, _pp); } sw.Stop(); Console.WriteLine("DD-Self2: nIter = " + nIter + " time = " + sw.ElapsedMilliseconds); return(sw.ElapsedMilliseconds / (double)nIter); }