Calculate Rotation Matrix to align Vector A to Vector B in 3d? I have one triangle in 3d space that I am tracking in a simulation. Between time steps I have the the previous normal of the triangle and the current normal of the triangle along with both the current and previous 3d vertex positions of the triangles.

Using the normals of the triangular plane I would like to determine a rotation matrix that would align the normals of the triangles thereby setting the two triangles parallel to each other. I would then like to use a translation matrix to map the previous onto the current, however this is not my main concern right now. 

I have found this website http://forums.cgsociety.org/archive/index.php/t-741227.html
that says I must 


determine the cross product of these two vectors (to determine a rotation axis)
determine the dot product ( to find rotation angle)
build quaternion (not sure what this means)
the transformation matrix is the quaternion as a 3 by 3 ( not sure)


Any help on how I can solve this problem would be appreciated.
Suppose you want to find a rotation matrix $R$ that rotates unit vector $a$ onto unit vector $b$.

Proceed as follows:

Let $v = a \times b$

Let $s = \|v\|$ (sine of angle)

Let $c = a \cdot b$ (cosine of angle)

Then the rotation matrix R is given by:
$$R = I + [v]_{\times} + [v]_{\times}^2\frac{1-c}{s^2},$$

where $[v]_{\times}$ is the skew-symmetric cross-product matrix of $v$,
$$[v]_{\times} \stackrel{\rm def}{=} \begin{bmatrix}
\,\,0 &amp; \!-v_3 &amp; \,\,\,v_2\\
\,\,\,v_3 &amp; 0 &amp; \!-v_1\\
\!-v_2 &amp; \,\,v_1 &amp;\,\,0
\end{bmatrix}.$$

The last part of the formula can be simplified to
$$
\frac{1-c}{s^2} = \frac{1-c}{1-c^2} = \frac{1}{1+c},
$$
revealing that it is not applicable only for $\cos(\angle(a, b)) = -1$, i.e., if $a$ and $b$ point into exactly opposite directions.
I have a simpler method comes from Erigen's "Mechanics of Continua". R is rotational matrix that rotate vector "a" align with vector "b" Matlab Code:

%%%%%% Rotate vector a align with vector b%%%%%%%%%% 

syms ax ay az bx by bz k real

a=[ax ay az]'
au=a./sqrt(ax^2+ay^2+az^2)

b=[bx by bz]'
bu=b./sqrt(bx^2+by^2+bz^2)

R=[bu(1)*au(1) bu(1)*au(2) bu(1)*au(3);

   bu(2)*au(1) bu(2)*au(2) bu(2)*au(3);

   bu(3)*au(1) bu(3)*au(2) bu(3)*au(3)]


To verify:

c=R*a
cu=c./sqrt(c(1)^2+c(2)^2+c(3)^2)
simple(bu-cu)


A zero result means that $c$ (rotated $a$) and $b$ are aligned with each other.

simple(sqrt(c(1)^2+c(2)^2+c(3)^2)-sqrt(c(1)^2+c(2)^2+c(3)^2))


A zero result means that $c$ (rotated $a$) and $a$ are of the same length.