# Calculation of rotation matrix given two vectors breaks when inverting matrix

I have a rotation in 3d (using the Euler angles) of the form: $$\boldsymbol{x}' = A \boldsymbol{x}.$$ Following the mathworld from Wolfram page, this can be manipulated to give: $$A = \boldsymbol{x}'\boldsymbol{x}(\boldsymbol{x}\boldsymbol{x}^{T})^{-1}.$$

However, the matrix $\boldsymbol{x}\boldsymbol{x}^{T}$ is singular, or at least when considering arbitrary components it seems the determinant is zero.

I am confused as to why this is since the Wolfram site makes no mention of this fact. It seems to suggest that you cannot calculate $A$ using this method? Does anyone have any ideas where I have gone wrong or if there is a better way to do this.

Edit for clarity: The $\boldsymbol{x}$ and $\boldsymbol{x}'$ are 3x1 vectors. Then the term I claim is singular in arbitrary components is:

$$\boldsymbol{x} \boldsymbol{x}^{T} = \left[ \begin{array}{c} x_{1} \\ x_{2} \\ x_{3} \end{array} \right] \left[ \begin{array}{ccc} x_{1} & x_{2} & x_{3} \end{array} \right] = \left[ \begin{array}{ccc} x_{1}x_{1} & x_{1}x_{2} & x_{1}x_{3} \\ x_{2}x_{1} & x_{2}x_{2} & x_{2}x_{3} \\ x_{3}x_{1} & x_{3}x_{2} & x_{3}x_{3} \end{array}\right]$$

$$\det(\boldsymbol{x} \boldsymbol{x}^{T}) = x_{1}^{\;2}(x_{2}^{\;2}x_{3}^{\;2} - x_{2}^{\;2}x_{3}^{\;2}) + \dots = 0$$

-
$x$ is a 3x3 matrix (this is why they write it as capital $X$) that has all 3 vectors of a basis, right? – Muphrid Aug 5 '13 at 13:27
Isn't $x x^T$ a diagonal matrix whose entries are the squared norms of the vectors in $x$? As long as all the vectors are non-zero it should be invertible. – Anthony Carapetis Aug 5 '13 at 13:32
@Muphrid I don't think that is the case, they simply say "Writing the arrays of vectors as matrices gives" by which I thought they meant they simply considered them as 3x1 matrices? Anthony: I am not sure, perhaps I am confused as to the meaning of $\boldsymbol{x}$ but I don't think it is diagonal. I'm happy to be told I am wrong. – Greg Ashton Aug 5 '13 at 13:47
2145647: I see. They're talking about doing a least-squares fit. That would make sense if the rotation is overdetermined, but using only one vector, is it not underdetermined? – Muphrid Aug 5 '13 at 13:53
@Muphrid I do not need to do the least squares fit only find A. I am not using one vector, I have $x'$ the rotated vector, and $x$ the original. The rotation matrix is composed of 3 angles so in theory we have enough information, but perhaps not to specify just A? – Greg Ashton Aug 5 '13 at 13:58