Changeset 25918 in project
 Timestamp:
 02/17/12 08:39:38 (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

release/4/spatialtrees/trunk/kdtree.scm
r25915 r25918 19 19 kdtreenearestneighbor 20 20 kdtreenearneighbors 21 kdtreeinearneighbors 21 22 kdtreeknearestneighbors 22 23 kdtreeremove … … 212 213 213 214 215 (define=> (makekdtreeinearneighbors <Point>) 216 (define (treeempty? t) (cases kdtree t (KdEmpty () #t) (else #f))) 217 (letrec ((nearneighbors 218 (lambda (t radius probe) 219 (cases kdtree t 220 (KdEmpty () '()) 221 (KdNode (l p i r axis) 222 (let ((maybepivot (if (<= (dist2 probe p) (* radius radius)) 223 (list (list i p)) '()))) 224 (if (and (treeempty? l) 225 (treeempty? r)) 226 maybepivot 227 (let ((xprobe (coord axis probe)) 228 (xp (coord axis p))) 229 (if (<= xprobe xp) 230 (let ((nearest (append maybepivot (nearneighbors l radius probe)))) 231 (if (> (+ xprobe (abs radius)) xp) 232 (append (nearneighbors r radius probe) nearest) 233 nearest)) 234 (let ((nearest (append maybepivot (nearneighbors r radius probe)))) 235 (if (< ( xprobe (abs radius)) xp) 236 (append (nearneighbors l radius probe) nearest) 237 nearest))) 238 )) 239 )) 240 )) 241 )) 242 nearneighbors 243 )) 244 245 214 246 215 247 ;; Returns the k nearest points to p within tree. … … 420 452 421 453 (define kdtreenearneighbors (makekdtreenearneighbors Pointpoint3d)) 454 455 (define kdtreeinearneighbors (makekdtreeinearneighbors Pointpoint3d)) 422 456 423 457 (define kdtreeknearestneighbors (makekdtreeknearestneighbors Pointpoint3d))
Note: See TracChangeset
for help on using the changeset viewer.