I have two 4d vectors, and need to calculate a $4\times 4$ rotation matrix to point from one to the other.
edit - I'm getting an idea of how to do it conceptually: find the plane in which the vectors lie, calculate the angle between the vectors using the dot product, then construct the rotation matrix based on the two. The trouble is I don't know how to mechanically do the first or last of those three steps. I'm trying to program objects in 4space, so an ideal solution would be computationally efficient too, but that is secondary.
Here's a different approach. Let the two vectors be $u$ and $v$, presumably they have the same length (otherwise no such rotation exists). Let $v'$ be a vector gotten from $v$ by flipping the sign of one its coordinates. I do it in two steps. First I find a reflection $S$ that maps $u\mapsto v'$. Then we multiply the result with a diagonal matrix $D$, where all the entries save one are $+1$, and there is a single $-1$ at the position of the flipped coordinate. As the determinants of both $S$ and $D$ are $-1$, and, being orthogonal reflections, they both obviously preserve the lengths of the vectors, the product $DS$ will thus be in $SO(4)$ (determinant one, and preserves lengths).
How to find $S$? This is easy. Let $n=v'-u$ be the difference vector. All we need to is to reflect w.r.t. the hyperlane $H$ that has $n$ as a normal. The formula for this reflection is $$ S(x)=x-2\,\frac{(x,n)}{(n,n)}n. $$ To find the matrix of $S$ all you need to do is to calculate the images of the basis vectors using that formula.
Numerical instabilities may happen, if $n$ is very short. If that happens, flip a different coordinate instead.