Beispiel #1
0
 private bool collinear3(List <int> b)
 {
     if (b.Count == 3)
     {
         return(Disc.Collinear(ps[b[0]], ps[b[1]], ps[b[2]]));
     }
     return(false);
 }
Beispiel #2
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);
        }