示例#1
0
        public void FixedRadiusSearch(QueryAndResultData data)
        {
            for (int i = 0; i < this.points.Length; i++)            // check points in bucket
            {
                IPoint pp = this.points[i];
                IPoint qq = data.QueryPoint;
                float  distanceToDataPoint = 0;
                int    d;

                for (d = 0; d < this.dimension; d++)
                {
                    float t = qq[d] - pp[d];
                    distanceToDataPoint += t * t;
                    if (distanceToDataPoint > data.SquaredSearchRadius)
                    {
                        break;                                                       // exceeds dist to k-th smallest?
                    }
                }

                if (d >= this.dimension)                                 // among the k best?
                {
                    data.ResultList.Add(this.points[i]);
                }
            }
        }
示例#2
0
        public void FixedRadiusSearch(QueryAndResultData data)
        {
            float cutDiff = data.QueryPoint[this.cuttingDimension] - this.cuttingValue; // distance to cutting plane

            if (cutDiff < 0)                                                            // left of cutting plane
            {
                if (cutDiff < -data.SearchRadius)
                {
                    this.leftChild.FixedRadiusSearch(data); // visit closer child first
                }
                else
                {
                    this.leftChild.FixedRadiusSearch(data);
                    this.rightChild.FixedRadiusSearch(data);
                }
            }
            else  // right of cutting plane
            {
                if (cutDiff > data.SearchRadius)
                {
                    this.rightChild.FixedRadiusSearch(data);    // visit closer child first
                }
                else
                {
                    this.leftChild.FixedRadiusSearch(data);
                    this.rightChild.FixedRadiusSearch(data);
                }
            }
        }
示例#3
0
        public List <IPoint> FixedRadiusSearch(IPoint queryPoint, float searchRadius)   // Search Radius bound
        {
            QueryAndResultData data = new QueryAndResultData()
            {
                QueryPoint          = queryPoint,
                SearchRadius        = searchRadius,
                SquaredSearchRadius = searchRadius * searchRadius
            };

            this.rootNode.FixedRadiusSearch(data);

            return(data.ResultList);
        }