Create example.m

This commit is contained in:
Ramy-Badr-Ahmed 2024-08-09 15:39:09 +02:00 committed by GitHub
parent 9b838d3e2c
commit 5084b058ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,17 @@
numPoints = 5000;
cubeSize = 10;
numDimensions = 10;
points = hypercubePoints(numPoints, cubeSize, numDimensions);
hypercubeKDTree = buildKDTree(points);
queryPoint = rand(1, numDimensions); % for the k-nearest neighbour search
[nearestPoint, nearestDist, nodesVisited] = nearestNeighbourSearch(hypercubeKDTree, queryPoint);
fprintf('Points in KD-Tree:\n');
fprintf('Query point: (%.2f, %.2f, %.2f)\n', queryPoint);
fprintf('Nearest point: (%.2f, %.2f, %.2f)\n', nearestPoint);
fprintf('Distance: %.4f\n', nearestDist);
fprintf('Nodes visited: %d\n', nodesVisited);