Finding all rotations that send one vector to another In a comment about an answer I gave in  Rotating one 3d-vector to another, @victorvalbert asks "What about finding all rotation matrices that rotate one point to another?" 
I wanted to provide an answer, so I've put it here so I can answer my own question, having a bit more room to do so. 
 A: $$
\newcommand{\bn}{\mathbf n}
\newcommand{\bu}{\mathbf u}
\newcommand{\bv}{\mathbf v}
\newcommand{\bR}{\mathbf R}
\newcommand{\bM}{\mathbf M}
\newcommand{\bA}{\mathbf A}
\newcommand{\bK}{\mathbf K}
\newcommand{\bD}{\mathbf D}
$$
First step: rotations preserve distance, so if $P$ and $Q$ are points whose distances from the origin are not equal, then there's no rotation matrix carrying one to the other. So let's restrict to pairs of points of the same radius. By scaling down by this radius, we might as well assume that the radius is $1$. So we're really asking "Given points on the unit sphere, what are all rotation matrices taking one to the other?" I'm going to replace the point $P$ on the sphere by the vector $v$ from the origin to $P$, just to be pedantic, so the question is now
"Given a pair of unit vectors $\bu$ and $\bv$, find all rotation matrices $\bM$ such that $\bM\bu = \bv$." 
Let's consider a simple case first: what are all the matrices that rotate $\bn = \pmatrix {0\\0\\1}$ to itself? That's pretty easy (geometrically): they're rotations in the $xy$-plane, i.e., each of them has the form 
$$
\bR_t = \pmatrix{\cos t & -\sin t & 0 \\
\sin t & \cos t & 0 \\
0 & 0 & 1}
$$
for some $0 \le t < 2\pi$. 
Hold that thought. 
Now lets look at the general case. From the answer to the related question, there's a matrix $\bM$ such that $\bM\bu = \bn$, where $\bn$ is the "north pole" vector as above. We can compute $\bv' = \bM\bv$, as well, and if we can find a matrix $\bA$ such that 
$$
\bA\bn = \bv'
$$
then we have
$$
\bA(\bM\bu) = \bM \bv,
$$
so that 
$$
\bM^{-1} \bA\bM\bu = \bv,
$$
i.e., every rotation matrix sending $\bu$ to $\bv$ is actually the conjugate of a matrix sending $\bn$ to $\bv'$ (and vice versa, which is equally easy to prove). Now let's find another rotation (again, using the answer to the original question) $\bK$ sending $\bn$ to $\bv$, i.e,
$$
\bK \bn = \bv.
$$
Then we can create a rotation from $\bu$ to $\bv$ as follows: rotate $\bu$ to the north pole $\bn$; rotate the north pole to itself by some rotation $\bR$; then rotate 
the north pole to $\bv$, i.e., we can build at least one of the desired rotations by generating
$$
\bD = \bK\bR\bM 
$$
But by moving things around in this equation, we get that 
$$
\bK^{-1}\bD\bM^{-1} = \bR.
$$
IN fact, if $\bD$ is any rotation taking $\bu$ to $\bv$, then $\bK^{-1}\bD\bM^{-1}$ must be a rotation taking $\bn$ to $\bn$, i.e., it must be $\bR_t$ for some $t$. So the rotation matrices that we're looking for are exactly
$$
\bD_t = \bK\bR_t\bM 
$$
where $0 \le t < 2\pi$. In other words: the set of rotations matrices in $SO(3)$ that send $\bu$ to $\bv$ is always (topologically) a circle in $SO(3)$. 
