Logo Euclid.BVH

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

this.Box

Full Usage: this.Box

Returns: BBox

The axis aligned bounding box around all lines in this LineBvh.

Returns: BBox

this.ClosePairs

Full Usage: this.ClosePairs

Parameters:
    maxDistance : 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.

maxDistance : 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.

this.ClosestLine

Full Usage: this.ClosestLine

Parameters:
    pt : 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.

pt : 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.

this.ClosestLine

Full Usage: this.ClosestLine

Parameters:
    query : 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.

query : 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.

this.ClosestPair

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.

Returns: LinePair

A LinePair with the indices of the two closest lines and their distance.

this.ClosestPoint

Full Usage: this.ClosestPoint

Parameters:
    pt : Pnt - The 3D point to search the closest point for.

Returns: Pnt The closest point on the closest line.

Finds the point on any line in the tree that is closest to the given 3D point.

pt : Pnt

The 3D point to search the closest point for.

Returns: Pnt

The closest point on the closest line.

this.Count

Full Usage: this.Count

Returns: int

The count of lines in this LineBvh.

Returns: int

this.Lines

Full Usage: this.Lines

Returns: IList<Line3D>

The input lines this LineBvh was built from. Do not mutate this array.

Returns: IList<Line3D>

this.LinesInBox

Full Usage: this.LinesInBox

Parameters:
    box : 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.

box : 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.

this.LinesNearPoint

Full Usage: this.LinesNearPoint

Parameters:
    pt : 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.

pt : 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.

this.NearestNeighbors

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.

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.

this.Tree

Full Usage: this.Tree

Returns: Bvh<Line3D>

The underlying generic Bvh of Line3D.

Returns: Bvh<Line3D>

Static members

Static member Description

LineBvh.DefaultLeafSize

Full Usage: LineBvh.DefaultLeafSize

Returns: int

The default maximum amount of lines per leaf node.

Returns: int

LineBvh.create (lines, ?leafSize)

Full Usage: LineBvh.create (lines, ?leafSize)

Parameters:
    lines : 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.

lines : 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.

Type something to start searching.