Coordinate transformation based on three points Consider two coordinate system $C_1$ and $C_2$. There are three points $p^1_1 $, $p^1_2$, and $p^1_3$ in coordinate $C_1$, where these points have $p^2_1$, $p^2_2$ and $p^2_3$ values in coordinate $C_2$. (note: $p^i_j \in R^3$) 
How can I find the transformation $T$ (in the form of $T=[R\hspace{0.2cm} t;0\hspace{0.2cm} 0\hspace{0.2cm} 0\hspace{0.2cm} 1]$ where $R$ is rotation matrix and $t$ is the translation vector) between these two coordinates such that for an arbitrary point in coordinate one like $p^1_4$, I can find it's value in coordinate two $p^2_4$ using $p^2_4 = T * P^1_4$.
Note1: I have used (Iterative Closest Point) ICP two find transformation between these two set of points. The computed transformation is correct for $p^2_1 = T * P^1_1$, $p^2_2 = T * P^1_2$ and $p^2_3 = T * P^1_3$. However for an arbitrary point $P^1_4$ the relation doesn't hold i.e $P^2_4 \neq T*P^1_4$.
Note 2: My points are as follows:
$P^1_1=[51.2,-206.6,1894.3];
P^1_2=[51.4, -157.6, 1893.6];
P^1_3=[-48.8, -206.6, 1894.2];$
$P^2_1=[-112.087, 181.788, 989];
P^2_2=[-115.62, 230.3, 987];
P^2_3=[-215.696, 185.55, 989];$
I expect to obtain transformation that the rotation part is close to identity matrix and it's just translation.
 A: You cannot find "the transformation between the coordinates" because no unique transformation exists. 
Example: in 3-space, let $p^1_1 = (0,0,0), p^1_1 = (1,0,0), p^1_2 = (0,1,0)$. Let $p^2_i = p^1_i$ for $i = 1 , 2, 3$. 
Then the identity map takes $p^1_i$ to $p^2_i$ for every $i$. But so does the map defined by 
$$T(x,y,z) = (x, y, 17z)$$
because your coordinate frames tell us nothing about the $z$ coordinate. 
This phenomenon isn't a fluke: an affine coordinate system with only three points doesn't suffice to generate coordinates on all of 3-space --- only on a 2D subspace. So when you find a mapping that takes one of your coordinate frames to the other, points outside the 2D subspace of the domain that the coordinates apply to can be sent anywhere. You need affine coordinate frames with four points (no three of which lie in a single plane); then uniqueness is easy.
A: For a 3D coordinate system:
$$\left(\begin{array}{c}p^2_{1x} \\p^2_{1y}  \\p^2_{1z} \end{array}\right)=T\left(\begin{array}{c}p^2_{1x} \\p^2_{1y}  \\p^2_{1z} \end{array}\right)$$
and similar for $p_2$ and $p_3$. We can write this in a matrix form:
$$\left(\begin{array}{ccc}p^2_{1x} &p^2_{2x} &p^2_{3x}\\p^2_{1y}&p^2_{2y} &p^2_{3y}\\p^2_{1z} &p^2_{2z}&p^2_{3z}\end{array}\right)=T\left(\begin{array}{ccc}p^1_{1x} &p^1_{2x} &p^1_{3x}\\p^1_{1y}&p^1_{2y} &p^1_{3y}\\p^1_{1z} &p^1_{2z}& p^1_{3z}\end{array}\right)$$
Then the matrix $T$ is given by $$T=\left(\begin{array}{ccc}p^2_{1x} &p^2_{2x} &p^2_{3x}\\p^2_{1y}&p^2_{2y} &p^2_{3y}\\p^2_{1z} &p^2_{2z}&p^2_{3z}\end{array}\right)\left(\begin{array}{ccc}p^1_{1x} &p^1_{2x} &p^1_{3x}\\p^1_{1y}&p^1_{2y} &p^1_{3y}\\p^1_{1z} &p^1_{2z}& p^1_{3z}\end{array}\right)^{-1}$$
The last matrix is invertible if the points are not collinear
A: First of all, you need at least four points to define the affine mapping. The second is that they should be vertices of some simplex, e.g. do not lie in one plane. If this two conditions are met you can always get the affine transformation in form
$$
\vec{X}(x_1; x_2; x_3) =
(-1)
\frac{
    \det
    \begin{pmatrix}
        0 & \vec{X}^{(1)} & \vec{X}^{(2)} & \vec{X}^{(3)} & \vec{X}^{(4)} \\
        \begin{matrix}
            x_{1} \vphantom{x_{1}^{(1)}} \\
            x_{2} \vphantom{x_{1}^{(1)}} \\
            x_{3} \vphantom{x_{1}^{(1)}} \\
        \end{matrix} &
%
        \begin{matrix}
            x_{1}^{(1)}  \\
            x_{2}^{(1)}  \\
            x_{3}^{(1)}  \\
        \end{matrix} &
%
        \begin{matrix}
            x_{1}^{(2)}  \\
            x_{2}^{(2)}  \\
            x_{3}^{(2)}  \\
        \end{matrix} &
%
        \begin{matrix}
            x_{1}^{(3)}  \\
            x_{2}^{(3)}  \\
            x_{3}^{(3)}  \\
        \end{matrix} &
%
        \begin{matrix}
            \!x_{1}^{(4)}\! \\
            \!x_{2}^{(4)}\! \\
            \!x_{n}^{(4)}\! \\
        \end{matrix} \\
%
        1 & 1 & 1 & 1 & 1
    \end{pmatrix}
}{
    \det
    \begin{pmatrix}
        \begin{matrix}
            x_{1}^{(1)} \\
            x_{2}^{(1)} \\
            x_{3}^{(1)} \\
        \end{matrix} &
%
        \begin{matrix}
            x_{1}^{(2)} \\
            x_{2}^{(2)} \\
            x_{3}^{(2)} \\
        \end{matrix} &
%
        \begin{matrix}
            x_{1}^{(3)} \\
            x_{2}^{(3)} \\
            x_{3}^{(3)} \\
        \end{matrix} &
%
        \begin{matrix}
            \! x_{1}^{(4)}\! \\
            \!x_{2}^{(4)}\! \\
           \! x_{n}^{(4)} \!\\
        \end{matrix} \\
%
        1 & 1 & 1 & 1
    \end{pmatrix}
},
$$
where $x_{1}$, $\dots$, $x_{n}$ are coordinates of vector-argument, $\vec{x}^{\,(1)}$, $\dots$, $\vec{x}^{\,(n+1)}$ are vertices of any simplex, while $\vec{X}^{(1)}$, $\dots$, $\vec{X}^{(n+1)}$ are their images in codomain. $x_i^{(j)}$ designates the $i$-th coordinate of the $j$-th vertex of the initial simplex.
You may want to look at this answer to get the idea how it works in 2D and how to rewrite it in canonical form rotation + translation. More details on why do you need your initial points to be vertices of some simplex you may find in "Beginner's guide to mapping simplexes affinely". Besides, you may find there more details on the equation above as described by its authors. More practical examples can be found in their recent "Workbook on mapping simplexes affinely". You may want to check it if you want to see solutions for more problems that are similar to this one.
