TITLE: How to solve an overdetermined system of point mappings via rotation and translation
QUESTION [7 upvotes]: I have a set of points in one coordinate system $P_1, \ldots, P_n$ and their corresponding points in another coordinate system $Q_1, \ldots , Q_n$. All points are in $\mathbb{R}^3$.
I'm looking for a "best fit" transformation consisting of a rotation and a translation.
I.e.
$$ \min_{A,b} \sum (A p_i + b - q_i)^2 , \quad A \in \operatorname{SO}(3), b \in \mathbb{R}^3$$
Can anyone give me some hint in which direction I should search?
I already looked at:
http://en.wikipedia.org/wiki/Least_squares  (don't know how to include the restriction to orthogonal matrices)
http://en.wikipedia.org/wiki/Singular_value_decomposition  (I thought that I'd start with a matrix from $\operatorname{GL}(3)$ and use the "best fit orthogonal matrix" afterwards like stated in http://en.wikipedia.org/wiki/Orthogonal_Procrustes_problem but that seamed too complicated)

REPLY [2 votes]: I try to summarize what I have to do in this answer:

Convert the $P_i$s and $Q_i$s:
$\overline{p}$ and $\overline{q}$ are the center of gravity for the set of points to be mapped:
$$ \overline{p} := \frac1i\sum_iP_i, \quad \overline{q} := \frac1i\sum_iQ_i$$
Make the points relative to their respective center of gravity:
$$ p_i := P_i - \overline{p}, \quad q_i := Q_i - \overline{q}$$
This removes the need to consider the translation $b$ in the optimization. $b$ can be calculated as $\overline{q} - A \overline{p}$ once we have determined the optimal $A$.

Calulate $B$ as
$$B = \left(\sum_i p q^\top \right)^\top = \sum_i q p ^\top$$

Perform SVD decomposition of $B$:
$$ B = U \Sigma V^\top$$

Optimal $A$ if $A \in \operatorname{O}(3)$ (not $A \in \operatorname{SO}(3)$ as stated in the question):
$$ A := U V^\top $$
Optimal $b$:
$$ b := \overline{q} - A \overline{p}$$

Optimal $A$ if $A \in \operatorname{SO}(3)$ would go here but I think $A \in \operatorname{O}(3)$ is what I'm really looking for.