Given 8 points in $\mathbb{R}^3$ and the prior knowledge that these points form the vertices of a cuboid, what is a computationally efficient way to order them?
When I say "cuboid" I refer to the set of all achievable shapes when starting from the canonical unit cube centred on the origin and applying independent scaling in x,y, z, then rigid rotation, then translation.
When I say "order", I mean that I want to know the relationships between all the vertices. For instance, with the ordering convention below, I can always say that vertex 1 is connected to vertices 2, 4, and 5 via an edge, and this remains true no matter what cuboid preserving transformation I apply to the points.
(furthest face from the viewpoint is shaded)
I've come up with a bunch of ideas that don't seem elegant, like computing euclidian distances and computing dot products of vectors formed by pairwise combinations of the points. I'm just wondering if there is an "elegant trick" out there.