# Rotate a 3D Vector onto Another 3D Vector

I am trying to transform one triangle onto another triangle in 3D space (Right Triangles). My thought was I align the forward and left vectors, then translate the center of one to the other.

Therefore, I am trying to find a way to rotate one vector such that it is facing in the same direction as the other vector. I have to rotate a 3D vector onto another 3D vector. I am only allowed to do rotations about the global x, y, and z.

I am using the following equation to create the 3D rotation matrix:

$$R = I + [v]_{\times} + [v]_{\times}^2{1-c \over s^2},$$

Where:

$v = a \times b$

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

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

However, I am running into issues. The first issue is when the cross product is 0, that does not necessarily mean the two vectors are facing in the same direction. Could be that they are parallel but 180degrees apart.

Second issue is, even though the vectors are facing the same direction, the triangles are still 180 degrees apart at the end:

Not sure what I am doing wrong.