public static DistanceSquared ( |
||
p1 | ||
p2 | ||
return | double |
public ISpatialCollection <T> getNeighborsInSphere(T item, double r) { double rSquared = r * r; // ISpatialCollection<T> neighbors = new SpatialCollectionAsBinLattice<T>(); IPosition position = (IPosition)item; LinkedList <T> possibleNeighbors = getBin(item); ISpatialCollection <T> neighbors = new SpatialCollectionAsList <T>(); foreach (T other in possibleNeighbors) { // DK: changed this: // IPosition otherPosition = (IPosition)other; // double d = position.getPoint3d().DistanceTo(otherPosition.getPoint3d()); // if (d < r && !Object.ReferenceEquals(item, other)) // { // neighbors.Add(other); // } // to this: if (!Object.ReferenceEquals(item, other)) { Point3d p1 = position.getPoint3d(); Point3d p2 = ((IPosition)other).getPoint3d(); if (Point.DistanceSquared(p1, p2) < rSquared) { neighbors.Add(other); } } } return(neighbors); }
public ISpatialCollection <T> getNeighborsInSphere(T item, double r) { double rSquared = r * r; // ISpatialCollection<T> neighbors = new SpatialCollectionAsBinLattice3<T>(); IPosition position = (IPosition)item; //LinkedList<T> possibleNeighbors = getBin(item); List <T> possibleNeighbors = getBins(item, r); ISpatialCollection <T> neighbors = new SpatialCollectionAsList <T>(); foreach (T other in possibleNeighbors) { if (!Object.ReferenceEquals(item, other)) { Point3d p1 = position.getPoint3d(); Point3d p2 = ((IPosition)other).getPoint3d(); if (Point.DistanceSquared(p1, p2) < rSquared) { neighbors.Add(other); } } } return(neighbors); }