If $a_i = [x_i, y_i]^T, b_i = [u_i, v_i]^T, i = 1, 2, \dots, N$, then the error function we're trying to minimize is
$ E = \displaystyle \sum_{i=1}^N ( b_i - (t + s R a_i) )^T (b_i - (t+ s R a_i)) $
where $s \gt 0 $ is a scale factor, and $R$ is a rotation matrix, and $t$ is a displacement vector.
In this setup, the sequence $\{b_i\}$ is allowed to be a scaled/rotated version of the sequence $\{a_i\}$ while still maintaining perfect similarity.
We want to find $\theta$ which determined the rotation matrix $R$, and $s$ that will result in minimum $E$.
Taking the partial derivative of $E$ with respect to $t$ gives
$ \nabla_t E = \displaystyle -2 \sum_{i=1}^N (b_i - (t + s R a_i)) = \mathbf{0} $
Hence,
$ N t = \displaystyle \sum_{i=1}^N (b_i - s R a_i ) $
i.e.
$ t = \dfrac{1}{N} \displaystyle \sum_{i=1}^N (b_i - s R a_i ) $
Taking the partial derivative of $E$ with respect to $\theta$ gives
$\dfrac{\partial E}{\partial \theta} = \displaystyle 2 \sum_{i=1}^N (b_i - (t + s R a_i))^T ( - \dfrac{\partial t }{\partial \theta} - s R' a_i ) = 0 $
This expands to
$ \displaystyle 2 \sum_{i=1}^N ( - b_i^T \dfrac{\partial t }{\partial \theta} - s b_i^T R' a_i + t^T \dfrac{\partial t }{\partial \theta} + s t^T R' a_i + s a_i^T R^T \dfrac{\partial t}{\partial \theta} + s^2 a_i^T R^T R' a_i) = 0 $
From the expression for $t$ above, we have
$ \dfrac{\partial t}{\partial \theta} = \dfrac{1}{N} \displaystyle \sum_{i=1}^N (-s R' a_i) $
Therefore,
$ \displaystyle \sum_{i=1}^N b_i^T \dfrac{\partial t }{\partial \theta} = \dfrac{1}{N} \sum_{i = 1 }^N \sum_{j=1}^N b_i^T (-s R' a_j ) $
At this point we note that
$ R = \begin{bmatrix} \cos \theta && - \sin \theta \\ \sin \theta && \cos \theta \end{bmatrix} = \cos \theta \ I + \sin \theta \ Q $
Where $I$ is identity matrix and $Q = \begin{bmatrix} 0 && -1 \\ 1 && 0 \end{bmatrix} $
Therefore
$ R' = \dfrac{\partial R}{\partial \theta} = - \sin \theta \ I + \cos \theta \ Q $
And we also note that $R^T R' = Q $, and that $Q$ is skew-symmetric, so for any vector $ w $, we have $w^T Q w = 0 $.
Therefore,
$\displaystyle \sum_{i=1}^N b_i^T \dfrac{\partial t }{\partial \theta} = \dfrac{-s}{N} \sum_{i = 1 }^N \sum_{j=1}^N b_i^T (- \sin \theta \ I + \cos \theta \ Q ) a_j $
And this evaluates to
$ \displaystyle \sum_{i=1}^N b_i^T \dfrac{\partial t }{\partial \theta} = \dfrac{-s}{N} ( - \sin \theta \ S_b^T S_a + \cos \theta \ S_b^T Q S_a ) $
where $S_a = \displaystyle \sum_{i=1}^N a_i $ and $ S_b = \displaystyle \sum_{i=1}^N b_i $
Moving on to the second term,
$ \displaystyle \sum_{i=1}^N b_i^T R' a_i = \sum_{i=1}^N b_i^T (- \sin \theta \ I + \cos \theta \ Q ) a_i = - \sin \theta S_1 + \cos \theta S_2 $
where $S_1 = \displaystyle \sum_{i=1}^N b_i^T a_i , S_2 = \displaystyle \sum_{i=1}^N b_i^T Q a_i $
Next, we have
$\displaystyle \sum_{i=1}^N t^T \dfrac{\partial t }{\partial \theta} = \dfrac{1}{N^2} \sum_{i=1}^N \sum_{j=1}^N \sum_{k=1}^N (b_j - s R a_j)^T (- s R' a_k ) $
And this evaluates to
$\displaystyle \sum_{i=1}^N t^T \dfrac{\partial t }{\partial \theta} = \dfrac{s}{N} ( \sin \theta \ S_b^T S_a - \cos \theta \ S_b^T Q S_a ) $
The next term is
$ \displaystyle \sum_{i=1}^N t^T R' a_i = \dfrac{1}{N} ( -\sin \theta S_b^T S_a + \cos \theta S_b^T Q S_a ) $
The next term is
$ \displaystyle \sum_{i=1}^N a_i^T R^T \dfrac{\partial t}{\partial \theta} = \dfrac{1}{N} \sum_{i=1}^N \sum_{j=1}^N - s a_i^T R^T R' a_j = 0 $
Also, the final terms is
$ \displaystyle \sum_{i=1}^N a_i^T R^T R' a_i = 0 $
This is because $R^T R' = Q$ which is a skew-symmetric matrix.
Now our equation becomes
$\dfrac{s}{N} ( - \sin \theta \ S_b^T S_a + \cos \theta \ S_b^T Q S_a ) -s(- \sin \theta S_1 + \cos \theta S_2) + \dfrac{s}{N} ( \sin \theta \ S_b^T S_a - \cos \theta \ S_b^T Q S_a ) + \dfrac{s}{N} ( -\sin \theta S_b^T S_a + \cos \theta S_b^T Q S_a ) = 0$
Dividing through by $s$, this equation becomes
$ \cos(\theta) ( \dfrac{1}{N} S_b^T Q S_a - S_2 ) + \sin(\theta) ( S_1 - \dfrac{1}{N} S_b^T S_a) = 0 $
Therefore, the optimal angle is given by
$ \boxed{\theta = \tan^{-1} \left( \dfrac{ N \ S_2 - S_b^T Q S_a }{ N \ S_1 - S_b^T S_a } \right)} $
Similarly, we can find the partial derivative of $E$ with respect to $s$, and equate it to zero, and this gives
$ \dfrac{\partial E}{\partial s } = 2 \displaystyle \sum_{i=1}^N (b_i - (t + s R a_i))^T (- (\dfrac{\partial t}{\partial s } + R a_i ) ) = 0 $
We note that
$ \dfrac{\partial t}{\partial s} = \dfrac{1}{N} \displaystyle \sum_{i=1}^N (- R a_i) = - \dfrac{1}{N} R S_a $
Expanding $\dfrac{\partial E}{\partial s}$ we get
$ \dfrac{\partial E}{\partial s} = 2 \displaystyle \sum_{i=1}^N (\dfrac{1}{N} b_i^T R S_a - b_i^T R a_i - \dfrac{1}{N} t^T R S_a + t^T R a_i - \frac{s}{N} a_i^T R^T R S_a + s a_i^T R^T R a_i) = 0 $
Recall that $ t = \dfrac{1}{N} (S_b - s R S_a)$. Hence, the summation evaluates to,
$ \dfrac{1}{N} S_b^T R S_a - (\cos \theta S_1 + \sin \theta S_2) - \dfrac{1}{N} (S_b - s R S_a)^T R S_a + \dfrac{1}{N} (S_b - s R S_a)^T (R S_a) - \dfrac{s}{N} S_a^T S_a + s S_3 $
where $S_3 = \displaystyle \sum_{i=1}^N a_i^T a_i $
This reduces to
$ - (\cos \theta S_1 + \sin \theta S_2) + \dfrac{1}{N} (S_b^T R S_a) - \dfrac{s}{N} S_a^T S_a + s S_3 = 0$
Substituting for $R = \cos \theta \ I + \sin \theta \ Q $, and multiplying through by $N$, gives
$ - N (\cos \theta S_1 + \sin \theta S_2) + (S_b^T (\cos \theta \ I + \sin \theta Q) S_a) - s S_a^T S_a + s N \ S_3 = 0$
This equation is linear in $s$. Hence,
$\boxed{s = \dfrac{ \cos(\theta) ( N S_1 - S_b^T S_a ) + \sin(\theta) ( N S_2 - S_b^T Q S_a) }{ N S_3 - S_a^T S_a } }$
The two expressions for $\theta$ and $s$ derived above result in the minimum $E$. To find the quality of similarity between the two point sequences $\{a_i\}$ and $\{b_i\}$, we just have to evalute the error function $E$ at this these values of $\theta$ and $s$.
As a quantitative measure, we can take the root of the average error per point $E$, i.e. compute
$ \Delta = \sqrt{ \dfrac{E}{N} } $
This gives an indication of how far (on average) is $b_i$ away from $(t + s R a_i)$.