in_quadtree
in_quadtree(point, C, W, CH)
Find quadtree cell containing point
Traverses a quadtree in logarithmic time to find the smallest cell (and every other cell) containing a given point in 2D space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point |
numpy double array
|
Query point coordinates |
required |
C |
numpy double array
|
Matrix of cell centers |
required |
W |
numpy double array
|
Vector of half cell widths |
required |
CH |
numpy int array
|
Matrix of child indices (-1 if leaf node) |
required |
Returns:
Name | Type | Description |
---|---|---|
i |
int
|
Index of smallest cell containint P into C,W,CH (-1 means the point is not in the quadtree) |
others |
numpy int array
|
others vector of integers to all other (non-leaf) cells containing P |
See Also
initialize_quadtree.
Notes
Only works for 2D quadtree. 3D functionality is coming soon.
Examples:
# Random points
P = np.random.rand(100,2)
# Get quadtree for random points
C,W,CH,PAR,D,A = gpytoolbox.initialize_quadtree(P,graded=True,max_depth=8)
# Query point
point = np.array([0.5,0.5])
# Find cell containing point
i,others = gpytoolbox.in_quadtree(point,C,W,CH)
Source code in src/gpytoolbox/in_quadtree.py
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|