/// <summary> /// This method requests the nodes in a rectangle /// </summary> /// <param name="rect">Rectange in which the nodes are searched</param> /// public void Query( Interval2D rect) { this.Query(this.root, rect); int i = 0; }
/// <summary> /// Evaluates if the interval2D intersects /// </summary> /// <param name="b">Evaluate the interval b</param> /// <returns>True if the invertals are intersected</returns> public bool Intersects( Interval2D b) { if (this.IntervalX.Intersects(b.IntervalX)) { return true; } if (this.IntervalY.Intersects(b.IntervalY)) { return true; } return false; }
/// <summary> /// This method requests the nodes in a rectangle in a node level /// </summary> /// <param name="h">The root node to be searched</param> /// <param name="rect">Rectange in which the nodes are searched</param> private void Query( Node h, Interval2D rect) { if (h == null) { return; } double xmin = rect.IntervalX.Low; double ymin = rect.IntervalY.Low; double xmax = rect.IntervalX.High; double ymax = rect.IntervalY.High; if (rect.Contains(h.X, h.Y)) { this.data.Add(h.Value); } if (this.Less(xmin, h.X) && this.Less(ymin, h.Y)) { this.Query(h.SW, rect); } if (this.Less(xmin, h.X) && !this.Less(ymax, h.Y)) { this.Query(h.NW, rect); } if (!this.Less(xmax, h.X) && this.Less(ymin, h.Y)) { this.Query(h.SE, rect); } if (!this.Less(xmax, h.X) && !this.Less(ymax, h.Y)) { this.Query(h.NE, rect); } }
/// <summary> /// Searching the points around of a position /// </summary> /// <param name="cpointsF">Point founds</param> /// <param name="nPn">Number of point searched</param> /// <param name="x">Coordinate X of the point to calculate</param> /// <param name="y">Coordinate Y of the point to calculate</param> public void ListPointAvailables( out List<Kpoint> cpointsF, double x, double y, double z, bool includePoint) { Kpoint center = new Kpoint(x, y, z, 0); if (kpoints.Count <= type * minPointsPerSector ) { if (includePoint) cpointsF = kpoints; else { cpointsF = new List<Kpoint>(); foreach (Kpoint k in kpoints) { if (!(k==center)) cpointsF.Add( k); } return; } } // double searchDistance = (this.extent[2] - this.extent[0]) * 0.05; double[] v = zone(center); double xsize=v[0]/2; double ysize = v[1]/2; double zsize = v[2]/2; double xmin=double.NaN; double ymin=double.NaN; double zmin=double.NaN; double xmax=double.NaN; double ymax = double.NaN; double zmax=double.NaN; int jj = 0; double dmult=0.1; do { ListToCheck = new List<KDistance>[type]; for (int i = 0; i < type; i++) { ListToCheck[i] = new List<KDistance>(); } mult = jj * dmult; this.quadTreeValues.Clean(); xmin = x - (xsize * (1 + mult )); ymin = y - (xsize * (1 + mult)); zmin = y - (zsize * (1 + mult)); xmax = x + (ysize * (1 + mult)); ymax = y + (ysize * (1 + mult)); zmax = y + (zsize * (1 + mult)); Interval intX = new Interval(xmin, xmax); Interval intY = new Interval(ymin, ymax); Interval intZ = new Interval(zmin, zmax); Interval2D rect = new Interval2D(intX, intY,intZ); this.quadTreeValues.Query(rect); dmult++; jj++; if (jj>1) v[1]=0; ConfigEllipse(center); } while (Conditions(center,this.quadTreeValues.GetData(),includePoint) && (v[0]*5) > Math.Abs(xmax-xmin) ); cpointsF = new List<Kpoint>(); for (int i = 0; i < type; i++) { int val=evaluteNumPoints(jj,ListToCheck[i].Count); for (int j = 0; j < ListToCheck[i].Count && j < val ; j++) cpointsF.Add(ListToCheck[i][j].point); } selectedPoints = cpointsF; }