示例#1
0
        /// <summary>
        /// Searches for the closest points in a hyper-sphere around the given center.
        /// </summary>
        /// <param name="center">The center of the hyper-sphere</param>
        /// <param name="radius">The radius of the hyper-sphere</param>
        /// <param name="neighboors">The number of neighbors to return.</param>
        /// <returns>The specified number of closest points in the hyper-sphere</returns>
        public KDTreeTuple <TDimension[], TNode>[] RadialSearch(TDimension[] center, double radius, int neighboors = -1)
        {
            var nearestNeighbors = new KDTreePriorityList <int, double>(this.Count);

            if (neighboors == -1)
            {
                this.SearchForNearestNeighbors(
                    0,
                    center,
                    HyperRect <TDimension> .Infinite(this.Dimensions, this.MaxValue, this.MinValue),
                    0,
                    nearestNeighbors,
                    radius);
            }
            else
            {
                this.SearchForNearestNeighbors(
                    0,
                    center,
                    HyperRect <TDimension> .Infinite(this.Dimensions, this.MaxValue, this.MinValue),
                    0,
                    nearestNeighbors,
                    radius);
            }

            return(nearestNeighbors.ToResultSet(this));
        }
示例#2
0
        /// <summary>
        /// Finds the nearest neighbors in the <see cref="KDTree{TDimension,TNode}"/> of the given <paramref name="point"/>.
        /// </summary>
        /// <param name="point">The point whose neighbors we search for.</param>
        /// <param name="neighbors">The number of neighbors to look for.</param>
        /// <returns>The</returns>
        public KDTreeTuple <TDimension[], TNode>[] NearestNeighbors(TDimension[] point, int neighbors)
        {
            var nearestNeighborList = new KDTreePriorityList <int, double>(neighbors, true);
            var rect = HyperRect <TDimension> .Infinite(this.Dimensions, this.MaxValue, this.MinValue);

            this.SearchForNearestNeighbors(0, point, rect, 0, nearestNeighborList, double.MaxValue);

            return(nearestNeighborList.ToResultSet(this));
        }