LineBvh Type
A static Bounding Volume Hierarchy (BVH) over 3D lines built from Euclid axis aligned bounding boxes (BBox). A thin wrapper around the generic Bvh of Line3D that measures distances between the exact line segments via XLine3D.getSqDistance. The tree is built once from an array of Line3D and is then immutable. It is well suited to unevenly distributed input because the tree adapts to the actual bounding boxes of the lines instead of subdividing space uniformly (as an octree or grid would). Typical queries, such as finding the closest line or all pairs of lines closer than a tolerance, run in about O(log n) per line instead of O(n) for a brute force scan.
Instance members
| Instance member |
Description
|
The axis aligned bounding box around all lines in this LineBvh.
|
|
Full Usage:
this.ClosePairs
Parameters:
float
-
The maximum distance between two lines for the pair to be reported.
Returns: ResizeArray<LinePair>
A ResizeArray of LinePair, each with IdxA less than IdxB. The order of the pairs is not defined.
|
Finds all pairs of lines that are closer to each other than the given maximum distance. Uses a dual tree traversal: pairs of subtrees whose bounding boxes are farther apart than the maximum distance are skipped entirely.
|
Full Usage:
this.ClosestLine
Parameters:
Pnt
-
The 3D point to search the closest line for.
?skipIdx : int
-
An index into the input lines array to exclude from the search. Optional, -1 (skip nothing) by default.
Returns: int * float
The index of the closest line in the input array and the distance from the point to it.
|
Finds the closest line in the tree to the given 3D point. The distance is measured to the exact (finite) line segments, while the bounding boxes are used for branch and bound pruning.
|
Full Usage:
this.ClosestLine
Parameters:
Line3D
-
The 3D line to search the closest line for.
?skipIdx : int
-
An index into the input lines array to exclude from the search.
Use this to find the nearest neighbor of a line that is part of the tree itself. Optional, -1 (skip nothing) by default.
Returns: int * float
The index of the closest line in the input array and the distance to it.
|
Finds the closest line in the tree to the given query line. Uses branch and bound: subtrees whose bounding box is farther away than the best distance found so far are skipped.
|
Full Usage:
this.ClosestPair
Returns: LinePair
A LinePair with the indices of the two closest lines and their distance.
|
Finds the pair of closest lines among all lines in the tree. For every line the nearest neighbor is searched with branch and bound pruning.
|
|
|
Full Usage:
this.Count
Returns: int
|
The count of lines in this LineBvh.
|
|
|
Full Usage:
this.LinesInBox
Parameters:
BBox
-
The axis aligned bounding box to search in.
?tolerance : float
-
The tolerance distance around the box. Optional, 0.0 by default.
Returns: ResizeArray<int>
A ResizeArray of the indices of the found lines in the input array.
|
Finds the indices of all lines whose bounding box is closer to the given axis aligned bounding box than the given tolerance.
|
Full Usage:
this.LinesNearPoint
Parameters:
Pnt
-
The 3D point to search around.
?tolerance : float
-
The tolerance distance around the point. Optional, 0.0 by default.
Returns: ResizeArray<int>
A ResizeArray of the indices of the found lines in the input array.
|
Finds the indices of all lines whose bounding box is closer to the given 3D point than the given tolerance.
|
Full Usage:
this.NearestNeighbors
Returns: LinePair[]
An array of LinePair. The entry at index i holds i as IdxA, the index of the
nearest neighbor of line i as IdxB and the distance between them.
|
For every line in the tree finds its nearest neighbor line.
|
Static members
| Static member |
Description
|
Full Usage:
LineBvh.DefaultLeafSize
Returns: int
|
The default maximum amount of lines per leaf node.
|
Full Usage:
LineBvh.create (lines, ?leafSize)
Parameters:
Line3D[]
-
The 3D lines to build the tree from. The array is referenced, not copied. Do not mutate it afterwards.
?leafSize : int
-
The maximum amount of lines per leaf node. Optional, 4 by default.
Returns: LineBvh
A new immutable LineBvh.
|
Builds a LineBvh from the given lines. The tree is built top-down by splitting at the median of the line-box centers along the longest axis of the current bounding box.
|
Euclid.BVH