public void ContainingTests()
 {
     Disc disc = new Disc(new Point(10, 0), new Point(-10, 0));
     Point[] points = new Point[] { new Point(0, 10), new Point(0, 12), new Point(0, -10), new Point(20, 0) };
     WriteLine("Trying correct except");
     int[] except = new int[] { 1, 3 };
     Assert.IsTrue(disc.Contains(points, except), "ContainingTest not working");
     WriteLine("Trying incomplete except");
     except = new int[] { 1 };
     Assert.IsFalse(disc.Contains(points, except), "ContainingTest not working");
     WriteLine("Trying empty and incorrect except");
     except = new int[] { };
     Assert.IsFalse(disc.Contains(points, except), "ContainingTest not working");
 }
示例#2
0
 public bool contains(Point p)
 {
     if (disc == null)
     {
         return(false);
     }
     return(disc.Contains(p));
 }
示例#3
0
        /// <summary>
        /// Computing the minimum enclosing disc the slow stupid way.  Just for testing purposes.
        /// </summary>
        /// <param name="points"></param>
        /// <returns>Smallest disc that encloses all the points</returns>
        public static Disc SlowComputation(Point[] points)
        {
            ValidateArg.IsNotNull(points, "points");
            int  n  = points.Length;
            Disc mc = null;

            int[] b = null;
            for (int i = 0; i < n; ++i)
            {
                for (int j = 0; j < n; ++j)
                {
                    if (i != j)
                    {
                        Disc c = new Disc(points[i], points[j]);
                        if (c.Contains(points, new int[] { i, j }))
                        {
                            if (mc == null || mc.Radius > c.Radius)
                            {
                                mc = c;
                                b  = new int[] { i, j };
                            }
                        }
                    }
                    for (int k = 0; k < n; ++k)
                    {
                        if (k != i && k != j && !Disc.Collinear(points[i], points[j], points[k]))
                        {
                            Disc c3 = new Disc(points[i], points[j], points[k]);
                            if (c3.Contains(points, new int[] { i, j, k }))
                            {
                                if (mc == null || mc.Radius > c3.Radius)
                                {
                                    mc = c3;
                                    b  = new int[] { i, j, k };
                                }
                            }
                        }
                    }
                }
            }
            Debug.Assert(b != null);
            return(mc);
        }
 /// <summary>
 /// Computing the minimum enclosing disc the slow stupid way.  Just for testing purposes.
 /// </summary>
 /// <param name="points"></param>
 /// <returns>Smallest disc that encloses all the points</returns>
 public static Disc SlowComputation(Point[] points)
 {
     ValidateArg.IsNotNull(points, "points");
     int n = points.Length;
     Disc mc = null;
     int[] b = null;
     for (int i = 0; i < n; ++i)
     {
         for (int j = 0; j < n; ++j)
         {
             if (i != j)
             {
                 Disc c = new Disc(points[i], points[j]);
                 if (c.Contains(points, new int[] { i, j }))
                 {
                     if (mc == null || mc.Radius > c.Radius)
                     {
                         mc = c;
                         b = new int[] { i, j };
                     }
                 }
             }
             for (int k = 0; k < n; ++k)
             {
                 if (k != i && k != j && !Disc.Collinear(points[i],points[j],points[k]))
                 {
                     Disc c3 = new Disc(points[i], points[j], points[k]);
                     if (c3.Contains(points, new int[]{i,j,k}))
                     {
                         if (mc == null || mc.Radius > c3.Radius)
                         {
                             mc = c3;
                             b = new int[] { i, j, k };
                         }
                     }
                 }
             }
         }
     }
     Debug.Assert(b != null);
     return mc;
 }