K-d tree: Difference between revisions

Content added Content deleted
(Updated both D entries)
m (Explicit string concat in second D entry)
Line 547: Line 547:


void randPt(size_t dim=3)(ref KdNode v, ref Xorshift rng) nothrow {
void randPt(size_t dim=3)(ref KdNode v, ref Xorshift rng) nothrow {
foreach (i; Iota!dim) {
foreach (immutable i; Iota!dim)
v.x[i] = rng.front / double(Xorshift.max);
v.x[i] = rng.uniform01;
rng.popFront;
}
}
}


Line 565: Line 563:
nearest!2(root, thisPt, 0, found, bestDist, nVisited);
nearest!2(root, thisPt, 0, found, bestDist, nVisited);


writefln("WP tree:\n Searching for %s\n"
writefln("WP tree:\n Searching for %s\n" ~
" Found %s, dist = %g\n Seen %d nodes.\n",
" Found %s, dist = %g\n Seen %d nodes.\n",
thisPt.x[0..2], found.x[0..2], sqrt(bestDist), nVisited);
thisPt.x[0..2], found.x[0..2], sqrt(bestDist), nVisited);