Changeset 18334
- Timestamp:
- Jun 26, 2008, 12:44:37 PM (18 years ago)
- Location:
- trunk/psLib/src/types
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psTree.c
r18317 r18334 461 461 } 462 462 463 464 // Given an arbitrary point, return the index of the nearest neighbour 465 long psTreeNearest(const psTree *tree, const psVector *coords) 463 // Return the index of the nearest neighbour to given coordinates, within some radius 464 // This is the engine for psTreeNearest() and psTreeNearestWithin() 465 static inline long treeNearestWithin(const psTree *tree, // Tree 466 const psVector *coords, // Coordinates of interest 467 double bestDistance // Distance (radius-squared) to best point 468 ); 466 469 { 467 470 #if 1 // Might be in a tight loop … … 475 478 psTreeNode *leaf = psTreeLeaf(tree, coords); // Leaf containing the point of interest 476 479 long bestIndex = -1; // Index of best point 477 double bestDistance = INFINITY; // Distance to best point478 480 treeLeafSearchNearest(&bestIndex, &bestDistance, tree, leaf, coords); 479 481 … … 515 517 } 516 518 519 // Given an arbitrary point, return the index of the nearest neighbour 520 long psTreeNearest(const psTree *tree, const psVector *coords) 521 { 522 return treeNearestWithin(tree, coords, INFINITY); 523 } 524 525 526 long psTreeNearestWithin(const psTree *tree, const psVector *coords, double radius) 527 { 528 return treeNearestWithin(tree, coords, PS_SQR(radius)); 529 } 530 531 517 532 // Search a leaf node for points within radius squared 518 533 static inline long treeLeafSearchWithin(double radius2, // Radius squared to search -
trunk/psLib/src/types/psTree.h
r18317 r18334 89 89 ); 90 90 91 /// Return the index of the nearest neighbour to given coordinates, but within some radius 92 long psTreeNearestWithin(const psTree *tree, ///< Tree 93 const psVector *coords ///< Coordinates of interest 94 double radius ///< Radius of interest 95 ); 96 91 97 /// Return the number of points within some radius of given coordinates 92 98 long psTreeWithin(const psTree *tree, ///< Tree
Note:
See TracChangeset
for help on using the changeset viewer.
