TITLE: is there an efficient algorithm for comparing collections of points?
QUESTION [12 upvotes]: Let's say you have two sets of M points $p_1...p_M$, and $q_1...q_M$, which reside in $\mathbb{R}^N$.  Is there an efficient (e.g. polynomial in M and N) algorithm to determine if the point-sets are the same up to some orthogonal transformation? I.e. $\exists O$ where $O^T O=I$ s.t. $p_i = O q_i, i=1...M$.

REPLY [3 votes]: Yes.  Compute the singular value decomposition of the two sets of points (as matrices of vectors of their coordinates).  If the singular values do not agree, then there is no orthogonal matrix mapping one to the other.  If the singular values do agree, then the singular vectors are an orthogonal coordinate system in which the two sets may be identical, which is easy to check since now you may sort the points with respect to their projection onto the first singular vector, which splits them into bins -- if the bins are all the same cardinality, sort each bin by projection onto the second singular vector, which splits them into subbins -- if the subbins are all the same cardinality, sort each subbin by projection onto the third singular vector, ..., and so on.  Either some sub-...-subbin has mismatched cardinality, so that the point sets are not orthogonally related, or each bin is reduced to cardinality one, so is trivial to verify matches, or is reduced to sets of points whose coordinates agree completely.  At each step, you either find the points don't match, or you end up showing that they do.
Note that this method will actually determine if there is a translation followed by a rotation that maps the one point set onto the other.  (This is because the SVD ignores the mean of the set of points, and you can too: translate one mean to the other then rotate.)  If you do not want to permit the two point clouds to have different means, then check for this first.  If they do have matched means, then apply the above.
As an aside, since the problem doesn't actually request the orthogonal matrix:  Transforming the set of singular vectors for one point set to the set of singular vectors to the other, to compute the orthogonal transformation between them, is straightforward.  (Really.  It's just a change of basis between orthogonal bases.)
The SVD is $O(N^2M + M^3)$.  The projections are at worst $O(NM)$.  The sorting is at worst $O(NM \log M)$ (since we're only sorting on the pseudo-real number projections, not some sort of lexicographic order) and cannot be this bad since the direction of the largest dispersion in the set of points is captured in the first singular vector (so there can't be only a single occupied bin in the first few recursions of the sorting-into-bins phase).  We can actually be sloppy in the sorting-into-bins phase and only sort into bins instead of to precise projections.  (This will be necessary if the projections are computed to finite precision since we would not want to reject two points which agree up to the precision of the multiply and accumulates in the comparison.)  The asymptotic running time estimates above assume constant time arithmetic, which may not be the case if you are using something more complicated that machine precision floating point representations of the coordinates.