Exercises about rotations 
$1.$Find  the axis and rotation angle of $T$ such that $T(v)=w$, for $v=(2,0,2)$ and $w=(0,2,-2)$. In case there is not such rotation, explain why.
$2.$ Say if it is possible to define a rotation $A$ about some axis passing through the origin such that $A(1,1,1)=(0,\sqrt 2,1)$.

I took the rotation about the $X,Y$ and $Z$ axes but it did not work. There is a general formula, I would like to know if there is another way to solve that kind of exercise
Knowing how to do this exercise I can try  this other one.
Thank you!
 A: For (1), since both the vectors have the same magnitude, such a rotation is possible. To get the axis about which to rotate, one possibility is on that is perpendicular to both vectors. This is because in moving from one vector to the other, we stay in the plane defined by them. So, the axis is just the cross product of $v$ and $w$. 
Now for the angle, it is easy to find the angle between two vectors. This is given by:
$$\cos(\theta) = \frac{v.w}{||v|| ||w||}$$
For an implementation in python, check out this library (rotate_vec2vec method): https://github.com/ryu577/pyray/blob/master/pyray/rotation.py
A: Problem 2:
$$A (1,1,1) = (0, \sqrt 2, 1)$$
Lets define a rotation axis $N = (1,1,1) \times (0, \sqrt 2, 1)$
We should also define two orthogonal vectors $U$ and $V$ in the rotation plane with normal $N$.
We can find $U$ by projecting $(1,1,1)$ into the plane with normal $N$.
$$U = (1,1,1) - \frac{N \cdot (1,1,1)}{N \cdot N} N$$
Since $N \cdot (1,1,1) = 0$ then:
$$U = (1,1,1)$$
And $V$ can be found as the cross product:
$$V = N \times U$$
For the sake of simplicity on the formulations  we assume that $U$, $V$ and $N$ are normalized vectors from now on. 
We define the matrix $M = [U V N]$, having the the vectors $U$, $V$ and $N$ as columns.
Let also define the coordinate vectors $E_1 = (1,0,0)$, $E_2 = (0,1,0)$ and $E_3 = (0,0,1)$. The matrix $M$ map the coordinate vectors with vectors $U$, $V$ and $N$.
$$M E_1 = U$$
$$M E_2 = V$$
$$M E_3 = N$$
Conversely $M^T$ map the vectors $U$, $V$ and $N$ to the coordinate vectors $E_1$, $E_2$ and $E_3$.
Now, we define the rotation matrix $R$ that rotates an angle $\theta$ around the $E_3$ axis. Where $\theta$ is:
$$\theta = \cos^{-1} (\frac{(1,1,1) \cdot (0, \sqrt 2, 1)}{\|(1,1,1)\| \|(0, \sqrt 2, 1)\|} )$$
Finally the matrix $A$ would be:
$$A = M R M^T$$
To show that the matrix $A$ is doing a rotation in the $U V$ plane around the nornal $N$ we can derive the formula:
$$A (1,1,1) = M R M^T (1,1,1)$$
Since $(1,1,1) = U$:
$$A (1,1,1) = M R M^T U$$
Since $M^T U = E_1$:
$$A (1,1,1) = M R E_1$$
Since $R E_1 = \cos(\theta) E_1 + \sin(\theta) E_2$:
$$A (1,1,1) = \cos(\theta) M E_1 + \sin(\theta) M E_2$$
Recalling that $M E_1 = U$ and $M E_2 = V$:
$$A (1,1,1) = \cos(\theta) U + \sin(\theta) V$$
Which is a meaningful result to keep in mind.
