new KDTree3D(points)
Creates a new KDTree instance from an array of 3D points.
Parameters:
| Name | Type | Description |
|---|---|---|
points |
Array.<PD.Point> | The array of points to search through. |
Methods
-
buildTree(points, depth)
-
Recursively builds a 3D KD tree.
Parameters:
Name Type Description pointsArray.<Object> Array of points, each with {x, y, z}.
depthnumber The current depth within the tree.
Returns:
A node representing part of the KD tree.
- Type
- Object | null
-
closestPoints(queryPoint, radius)
-
Finds all points within a given radius from the query point.
Parameters:
Name Type Description queryPointObject The query point {x, y, z}.
radiusnumber The radius within which to search.
Returns:
Array of points within the given radius.
- Type
- Array.<Object>
-
nearest(queryPoint [, k])
-
Finds the k-nearest neighbors to the given query point.
Parameters:
Name Type Argument Default Description queryPointObject The query point {x, y, z}.
knumber <optional>
1 Number of nearest neighbors to return.
Returns:
Array of the k closest points.
- Type
- Array.<Object>
-
squaredDistance(a, b)
-
Computes the squared Euclidean distance between two 3D points.
Parameters:
Name Type Description aObject First point {x, y, z}.
bObject Second point {x, y, z}.
Returns:
The squared distance.
- Type
- number
-
fromPath(path) <static>
-
Creates a new KDTree instance from path points in a given path.
Parameters:
Name Type Description pathArray.<BIM.Path> The path to search through.
Returns:
Returns a new KDTree instance.
- Type
- KDTree
-
fromPaths(paths) <static>
-
Creates a new KDTree instance from points in the given paths.
Parameters:
Name Type Description pathsArray.<BIM.Path> The list of paths to search through.
Returns:
Returns a new KDTree instance.
- Type
- KDTree