Calculating the rotation point between 2 sets of points I've been trying to solve this for a while but I can't figure it out.
I have 2 sets of points: p1, p2 and p1', p2'.
p1(x1,y1), p2(x2,y2) and p1'(x1',y1'), p2'(x2',y2') all known values.
Those 2 sets are the same but are rotated around a point ($p_c$). I want to find that point's ($p_c$) coordinates.
small sketch of both data sets with the center of rotation
At first I tried this (I set some points and rotated them around the coordinates (0.5,-0.5) so that I know if I find the correct result):
Since I know all the points, I took this:
$$
\begin{bmatrix}
x_1'\\ 
y_1'\\
1\\
\end{bmatrix}
=
\begin{bmatrix}
cosθ & -sinθ & x_c\\ 
sinθ & cosθ & y_c\\
0 & 0 & 1\\
\end{bmatrix}
\begin{bmatrix}
x_1\\ 
y_1\\
1\\
\end{bmatrix}
$$
Let's note it this way: $B = XA$
I isolated X to get this: $X=BA^T(AA^T)^{-1}$ and naively thought I'd get my $x_c$ and $y_c$, but the resulted X was
$$
\begin{bmatrix}
0.7071 & -0.7071 & -0.2071\\ 
0.7071 & 0.7071 & -0.5\\
3.7919e^{-16} & 3.8203e^{-15} & 1\\
\end{bmatrix}
$$
This transformation matrix is correct, when I tranform my points using it, the point's shift to where they should be. But although there's -0.5 for $y_c$, the $x_c$ is wrong.
Next I thought I'd try and take this "formula?/operation": (It takes a x,y point, translates to the origin of the axis, rotate, and translate back, basically rotating around a point that is not the origin)
$$
\begin{bmatrix}
x_1'\\ 
y_1'\\
1\\
\end{bmatrix}
=
\begin{bmatrix}
1 & 0 & x_c\\ 
0 & 1 & y_c\\
0 & 0 & 1\\
\end{bmatrix}
\begin{bmatrix}
cosθ & -sinθ & 0\\ 
sinθ & cosθ & 0\\
0 & 0 & 1\\
\end{bmatrix}
\begin{bmatrix}
1 & 0 & -x_c\\ 
0 & 1 & -y_c\\
0 & 0 & 1\\
\end{bmatrix}
\begin{bmatrix}
x_1\\ 
y_1\\
1\\
\end{bmatrix}
$$
Let's not it this way: $C1 = T*R*T^{-1}*C0$ where is known everything but x and y (θ the angle of the line is easely calculated)
But I don't know how to isolate $T$ and $T^{-1}$ (which if I could I'd just have $T*T^{-1}$ which wouldn't get me very far.)
Do you have any insight on what I should be doing? I feel like I'm way off course on this one.
 A: Use the fact that the perpendicular bisectors of segments $p_1 p'_1 $  and $p_2 p'_2$ pass through the center of rotation $p_0$.  Therefore, if
$n_1 = p'_1 - p_1 $
$n_2 = p'_2 - p_2 $
and
$m_1 = \dfrac{1}{2} (p'_1 + p_1 ) $
$m_2 = \dfrac{1}{2} (p'_2 + p_2 ) $
and
$p_0 = (x, y) $
then
$n_1^T (p_0 - m_1) = 0 $
$n_2^T (p_0 - m_2 ) = 0 $
So that by matrix inversion, we get the center of rotation $p_0$
$p_0 = \begin{bmatrix} n_1^T \\ n_2^T \end{bmatrix}^{-1} \begin{bmatrix} n_1^T m_1 \\n_2^T m_2 \end{bmatrix} $
To get the angle of rotation, find the angle between the vector $p'_1 - p_0$ and $p_1 - p_0$.  This angle is equal to the angle between the vectors $p'_2 - p_0$ and $p_2 - p_0$.
A: Here's another solution, where the rotation matrix $R$ is calculated first, and then the center of rotation.
We have the following relation between $p_1, p'_1, p_2 , p'_2$ and the center of rotation $p_0$
$p'_1 = p_0 + R (p_1 - p_0) $
$p'_2 = p_0 + R(p_2 - p_0) $
Subtracting
$p'_2 - p'_1 = R (p_2 - p_1)$
Let $b = p'_2 - p'_1 $ and $ a = (p_2 - p_1) $
$a$ and $b$ are known vectors, having the same length $r$, thus
$ a = r ( \cos \theta_1 , \sin \theta_1 ) $
and
$b = r (\cos \theta_2, \sin \theta_2 ) $
Since
$R = \begin{bmatrix} \cos \phi && - \sin \phi \\ \sin \phi && \cos \phi \end{bmatrix} $
then
$R a = r ( \cos(\phi + \theta_1 ) , \sin(\phi + \theta_1 ) )$
Comparing this with $b$, we deduce that the rotation angle $\phi$ is given by
$ \phi = \theta_2 - \theta_1 $
So matrix $R$ is now known.  Back to the original equations
$p'_1 = p_0 + R (p_1 - p_0) = R p_1 + (I - R) p_0 $
From this equation we get
$p_0 = (I - R)^{-1} ( p'_1 - R p_1 ) $
Note that the determinant of $(I - R)$ is
$| I - R | = (1 - \cos \phi)^2 + \sin^2 \phi = 2 - 2 \cos \phi $
So the determinant is $0$ (singular matrix) only in the case $\phi = 0 $, which corresponds to no rotation at all.
