Rotation matrix for a 3D object in space This is the follow-up question from here: Minimum requirements to uniquely represent a 3D object in space

Assume I have 3 original points in a 3D object (in 3D space) as A1=&lt;xa,ya,za&gt;, A2=&lt;xa,ya,za&gt;, and A3=&lt;xa,ya,za&gt; (assume we have all the requirements mentioned in our previous question). The 3D object is moved and rotated in the 3D space, and the new destination points become B1=&lt;xb,yb,zb&gt;, B2=&lt;xb,yb,zb&gt;, and B3=&lt;xb,yb,zb&gt;. 

What is the formula for the transformation matrix? Basically, I need a matrix that if applied to all points of the origin object, I get the displaced object.
Skimming the math.  Starting with a quaternion $Q=w+\left(x,y,z\right)$ then we can rotate $\mathbf{v}$ by:

$$\mathbf{v}' = Q\mathbf{v}Q^{-1}$$

and if $Q$ is unit magnitude this reduces to:

$$\mathbf{v}' = Q\mathbf{v}Q^*$$

To create a matrix we need to apply the rotation to the basis set to form our three equations:

$$
\mathbf{x} = \left(1,0,0\right) \\
\mathbf{y} = \left(0,1,0\right) \\
\mathbf{z} = \left(0,0,1\right) \\
$$

which expanded and reduced gives:

$$
\mathbf{x}' = Q\mathbf{x}Q^{-1} = \left(1 - 2 \left(y^2+z^2\right), 2\left(xy+wz\right), 2\left(xz-wy\right) \right) \\
\mathbf{y}' = Q\mathbf{y}Q^{-1} = \left(2 \left(xy-wz\right), 1 - 2\left(x^2+z^2\right), 2\left(wx+yz\right) \right)  \\
\mathbf{z}' = Q\mathbf{z}Q^{-1} = \left(2 \left(wy+xz\right), 2\left(yz-wx\right), 1 - 2\left(x^2+y^2\right) \right)
$$

Sticking to the math convention of column vectors, then we shove the three equations into the first three columns and to add a translation by $\left(t_x,t_y,t_z\right)$ we shove that into the last column giving:

$$
{
\left( \begin{array}{ccc}
1 - 2 \left(y^2+z^2\right) &amp; 2\left(xy-wz\right)       &amp;  2\left(xz+wy\right)  &amp; t_x\\
2 \left(xy+wz\right)       &amp; 1 - 2\left(x^2+z^2\right) &amp;  2\left(wx-yz\right)  &amp; t_y \\
2 \left(wy-xz\right)       &amp; 2\left(yz+wx\right)       &amp; 1 - 2\left(x^2+y^2\right) &amp; t_z \\
0 &amp; 0 &amp; 0 &amp; 1
\end{array} \right)
}
$$