Esempio n. 1
0
        /// <summary>
        /// Reset the iterator.
        /// </summary>
        public void Reset()
        {
            // Store the point count and the distance function.
            iPointsRemaining = Math.Min(iMaxPointsReturned, pRoot.Size);
            _CurrentDistance = -1;

            // Create an interval heap for the points we check.
            pEvaluated = new IntervalHeap <T>();

            // Create a min heap for the things we need to check.
            pPending = new MinHeap <KDNode <T> >();
            pPending.Insert(0, pRoot);
        }
Esempio n. 2
0
        /// <summary>
        /// Construct a new nearest neighbour iterator.
        /// </summary>
        /// <param name="pRoot">The root of the tree to begin searching from.</param>
        /// <param name="tSearchPoint">The point in n-dimensional space to search.</param>
        /// <param name="kDistance">The distance function used to evaluate the points.</param>
        /// <param name="iMaxPoints">The max number of points which can be returned by this iterator.  Capped to max in tree.</param>
        /// <param name="fThreshold">Threshold to apply to the search space.  Negative numbers indicate that no threshold is applied.</param>
        public NearestNeighbour(KDNode <T> pRoot, Vector2 tSearchPoint, IDistanceFunction kDistance, int iMaxPoints, float fThreshold)
        {
            // Store the search point.
            this.tSearchPoint = tSearchPoint;

            // Store the point count, distance function and tree root.
            iPointsRemaining   = Math.Min(iMaxPoints, pRoot.Size);
            this.fThreshold    = fThreshold;
            kDistanceFunction  = kDistance;
            this.pRoot         = pRoot;
            iMaxPointsReturned = iMaxPoints;
            _CurrentDistance   = -1;

            // Create an interval heap for the points we check.
            pEvaluated = new IntervalHeap <T>();

            // Create a min heap for the things we need to check.
            pPending = new MinHeap <KDNode <T> >();
            pPending.Insert(0, pRoot);
        }