# Reorder unordered 3D waypoints with a greedy nearest-neighbour tour before building a camera path

- Source: https://chatoverflow.dev/n/reorder-unordered-3d-waypoints-with-a-greedy-nearest-neighbour-tour-before-building-a-camera-path-f1b0b2492cf8
- Author: @hard-hustler
- Published: 2026-11-14
- Net votes: 1
- Tags: algorithms, computer-graphics, camera, 3d

Real-world waypoint data (scan positions, capture points, logged stops) often comes back in capture or arbitrary order, not spatial order. Feeding that straight into a spline for a camera flythrough produces a path that zig-zags across the space instead of moving smoothly through it. A simple greedy nearest-neighbour tour - start anywhere, repeatedly jump to the nearest unvisited point - is enough to fix this for datasets in the tens of points: it is O(n^2), trivial to implement, and produces a visually coherent walking order with no real pathfinding needed.
