geometric hash code or is there a unique affine transformation mapping two 2D points onto (0,0) and (1,1)? How can I compute it? I have a 2D transformation $T$ composed by a scale $\lambda$, a rotation by angle $\theta$ and a translation vector $\begin{bmatrix}t_x\\t_y\end{bmatrix}$:
$$
    T=\begin{bmatrix}
    \lambda\cos(\theta) &     -\lambda\sin(\theta) & t_x \\
    \lambda\sin(\theta) & \lambda\cos(\theta) & t_y \\
    0 & 0 & 1 \\
    \end{bmatrix}
$$
$T$ operates on 2D point $P$ expressed with homogeneous coordinates:
$$
P=\begin{bmatrix}
x\\
y\\
1
\end{bmatrix}
$$
$T$ maps 2D $(x,y)$ point to 2D $(u,v)$ point according to:
$$
\begin{bmatrix}u\\v\\1\end{bmatrix}=TP
$$
Now I have 
$$
A=\begin{bmatrix}x_A\\y_A\\1\end{bmatrix},B=\begin{bmatrix}x_B\\y_B\\1\end{bmatrix}
$$
I would like to map $A$ to $(0,0)$ and $B$ to $(1,1)$:
$$\begin{bmatrix}0\\0\\1\end{bmatrix}=TA$$
$$\begin{bmatrix}1\\1\\1\end{bmatrix}=TB$$
Is $T$ unique?
How can I compute $T$?

Background information:

I am trying to compute an hash code as described in 
LANG, Dustin, et al. Astrometry.net: Blind astrometric calibration of arbitrary astronomical images. The astronomical journal, 2010, 139.5: 1782.
See here Figure 1 from the above paper:

 A: Herein bold Latin letters, ${\bf A}, {\bf B}, \ldots$, denote vectors in $\Bbb R^2$, so that the corresponding homogeneous coordinates are $\pmatrix{{\bf A}\\1}$, etc.
Yes, there is a unique solution, and we can see this uniqueness by carrying out a more-or-less explicit construction of the map itself. One way to do this intuitively is to apply three transformations of the form $T$ successively:


*

*one translation, $T_{\bf R} = \pmatrix{1&&r\\&1&s\\&&1}$---we denote ${\bf R} := \pmatrix{r\\s}$---

*one rotation, $T_{\theta} = \pmatrix{\cos \theta&-\sin\theta&\\ \sin\theta&\cos\theta&\\&&1}$, and

*one dilation, $T_{\lambda} = \pmatrix{\lambda&&\\&\lambda&\\&&1}$.


It's straightforward to check that a composition of two transformations of the given form also has that form, so $$T := T_{\lambda} \circ T_{\theta} \circ T_{\bf R}$$ will have that form.
First, note that rotations and dilations fix $\pmatrix{{\bf 0}\\1}$. So, since $T\pmatrix{{\bf A}\\1} = 0$, we must have $$\pmatrix{{\bf 0}\\1} = T_{\bf R}\pmatrix{{\bf A}\\1} = \pmatrix{{\bf A} + {\bf R}\\1}, $$
that is, $${\bf R} = -{\bf A} .$$
Any dilation by a positive constant $\lambda$ fixes rays, so if $T$ maps $\pmatrix{{\bf B}\\1}$ to $\pmatrix{1\\1\\1}$, the rotation by $\theta$ must map ${\bf B}' := {\bf B} - {\bf A}$ to the ray spanned by $(1, 1)$, and there is only one rotation that achieves this: If ${\bf B}'$ makes a (signed) angle $\alpha$ with the positive $x$-axis, then we can take $\theta = \frac{\pi}{4} - \alpha$. If you prefer an explicit formula, we can take $$\theta = \frac{\pi}{4} - \operatorname{atan2}(x_{{\bf B}'}, y_{{\bf B}'}) = \frac{\pi}{4} - \operatorname{atan2}(y_{\bf B} - y_{\bf A}, x_{\bf B} - x_{\bf A}) .$$ A little trigonometry, including the angle sum identities, then gives the more convenient formulas
$$\begin{align*}
\cos \theta &= \frac{x_{{\bf B}'} + y_{{\bf B}'}}{\sqrt{2} |{\bf B}'|} \\
\sin \theta &= \frac{x_{{\bf B}'} - y_{{\bf B}'}}{\sqrt{2} |{\bf B}'|}
\end{align*} .$$
Finally, the vector ${\bf B}''$ produced by rotating ${\bf B}'$ by an angle $\theta$ has length $|{\bf B}''| = |{\bf B} - {\bf A}|$ and $(1, 1)$ has length $\sqrt{2}$, so $$\lambda = \sqrt{2} |{\bf B} - {\bf A}|^{-1} .$$
If we want to produce explicit parameters, expanding $T = T_{\lambda} \circ T_{\theta} \circ T_{-{\bf A}}$ gives that $T$ is the transformation
$$T = \pmatrix{\lambda \cos \theta & -\lambda \sin \theta & t_x \\ \lambda \sin \theta & \lambda \cos \theta & t_y \\ &&1},$$
where
$$\begin{align}
t_x &= \lambda (-x_{\bf A} \cos \theta + y_{\bf A} \sin \theta) \\
t_y &= \lambda (-y_{\bf A} \sin \theta - x_{\bf A} \cos \theta)
\end{align} .$$
A: There's a very easy solution using complex numbers. A similarity transform is described by a linear relation
$$pz+m=w.$$
Then
$$a\to(0,0),\\b\to(1,1)$$
correspond to the system
$$\begin{cases}pa+m&=0,
\\pb+m&=1+i\end{cases}$$
so that
$$\begin{cases}p&=\dfrac{1+i}{b-a},\\m&=-pa.\end{cases}$$
In matrix form
$$\begin{pmatrix} p_r&-p_i\\p_i&p_r\end{pmatrix}\begin{pmatrix} x\\y\end{pmatrix}+\begin{pmatrix} m_r\\m_i\end{pmatrix}=\begin{pmatrix} x'\\y'\end{pmatrix}.$$
By converting $p$ to polar form, you get the scale and angle.
A: Partial solution
$ \begin{cases} 
\begin{align*}
0 &= x_{A}\lambda \cos(\theta) - y_{A}\lambda \sin(\theta) + t_{x} \\
0 &= x_{A}\lambda \sin(\theta) + y_{A}\lambda \cos(\theta) + t_{y} \\
0 &= x_{B}\lambda \cos(\theta) - y_{B}\lambda \sin(\theta) + t_{x} - 1\\
0 &= x_{B}\lambda \sin(\theta) + y_{B}\lambda \cos(\theta) + t_{y} - 1\\
\end{align*} 
\end{cases} $
Jacobian:
$J=\begin{bmatrix}
x_{A}\cos(\theta) - y_{A} \sin(\theta) & 
-x_{A}\lambda \sin(\theta) - y_{A}\lambda \cos(\theta) &
1 &
0 \\
x_{A}\sin(\theta) + y_{A}\cos(\theta) &
x_{A}\lambda \cos(\theta) - y_{A}\lambda \sin(\theta) &
0 &
1 \\
x_{B}\cos(\theta) - y_{B} \sin(\theta) & 
-x_{B}\lambda \sin(\theta) - y_{B}\lambda \cos(\theta) &
1 &
0 \\
x_{B}\sin(\theta) + y_{B}\cos(\theta) &
x_{B}\lambda \cos(\theta) - y_{B}\lambda \sin(\theta) &
0 &
1 \\
\end{bmatrix}$
The rows of J are independent unless:


*

*$\lambda = 0$ or 

*$x_{A} = x_{B}$ and $y_{A} = y_{B}$.


In that case, $J$ is invertible. 
However, that doesn't guarantee that there is only one solution:
Unique solution to system of nonlinear equations (non-singular Jacobian)
On the other hand, if $\lambda = 0$ is a solution, then the solution is not unique. I can linearize the system around the solution. Since the null space of the Jacobian is non-trivial, the solution is not unique.
That means if a translation can translate points A and B to $(0, 0)$ and $(1, 1)$, then the solution (in terms of $\lambda, \theta, t_{x}, t_{y}$)  is not unique. But in that case, $T$ is still unique.
