Exemple #1
0
        MinDisc mtf_md(LinkedListNode <int> lPtr, List <int> b)
        {
            Debug.Assert(b.Count <= 3);
            MinDisc md = new MinDisc(ps, b);

            if (b.Count == 3)
            {
                return(md);
            }

            LinkedListNode <int> lnode = L.First;

            while (lnode != null && lnode != lPtr)
            {
                LinkedListNode <int> lnext = lnode.Next;
                int p = lnode.Value;
                if (!md.contains(ps[p]))
                {
                    List <int> _b = new List <int>(b);
                    _b.Add(p);
#if DEBUG
                    Debug.Assert(!collinear3(_b), "Collinear points on boundary of minimal enclosing disc");
#endif
                    md = mtf_md(lnode, _b);
                    L.Remove(lnode);
                    L.AddFirst(lnode);
                }
                lnode = lnext;
            }
            return(md);
        }
Exemple #2
0
        public MoveToFront(Point[] ps)
        {
            ValidateArg.IsNotNull(ps, "ps");
            this.ps = ps;
            L       = new LinkedList <int>();
            for (int i = 0; i < ps.Length; ++i)
            {
                L.AddLast(i);
            }
            MinDisc md = mtf_md(null, new List <int>());

            disc     = md.disc;
            boundary = md.boundary;
        }
         MinDisc mtf_md(LinkedListNode<int> lPtr, List<int> b)
        {
            Debug.Assert(b.Count <= 3);
            MinDisc md = new MinDisc(ps,b);
            if (b.Count == 3)
            {
                return md;
            }
            LinkedListNode<int> lnode = L.First;
            while(lnode!=null&&lnode!=lPtr)
            {
                LinkedListNode<int> lnext = lnode.Next;
                int p = lnode.Value;
                if (!md.contains(ps[p]))
                {
                    List<int> _b = new List<int>(b);
                    _b.Add(p);
#if DEBUG
                    Debug.Assert(!collinear3(_b),"Collinear points on boundary of minimal enclosing disc");
#endif
                    md = mtf_md(lnode, _b);
                    L.Remove(lnode);
                    L.AddFirst(lnode);
                }
                lnode = lnext;
            }
            return md;
        }