xD So fine I'll bite, basically the article Le Verdier posted has it. If you want to know how the matrix works:
The article does a kinda neat trick. In Mathematica form, the matrix Txz looks like this:
txz={{u/Sqrt[u^2 + v^2], v/Sqrt[u^2 + v^2], 0},
{-v/Sqrt[u^2 + v^2], u/Sqrt[u^2 + v^2], 0},
{0, 0, 1}};
(where, each {a,b,c} block is a row)
with the neat property that it's a rotation, and if you right-multiply it by the vector {u,v,w} (column vector), you get {Sqrt[u^2+v^2],0,w}. Meaning, you pull the vector {u,v,w} down on to the xz plane, and it's a rotation, so if you plug in some other arbitrary {x,y,z} vector, it gets rotated, "as you would expect".
Then, once you have the vector in the xz plane, you move it so that it's just on the positive z axis, which looks like this:
tz={{w/Sqrt[u^2 + v^2 + w^2], 0, -Sqrt[u^2 + v^2]/Sqrt[u^2 + v^2 + w^2]},
{0, 1, 0},
{Sqrt[u^2 + v^2]/Sqrt[u^2 + v^2 + w^2], 0, w/Sqrt[u^2 + v^2 + w^2]}
};
with the properties that it's a rotation, and if you right multiply the column vector {Sqrt[u^2+v^2],0,w} to it (which is the result of the previous calculation), you get {0,0,Sqrt[u^2+v^2+w^2]} with s being some number which we don't really care about.
So since those are both rotations they have the properties we want, we can do those transformations, THEN rotate the vector around the z-axis, THEN apply the inverse transformations, to drag the z axis back to the place it was before.
to rotate something about the z axis is just:
r={{Cos[q],-Sin[q],0},{Sin[q],Cos[q],0},{0,0,1}};
Putting it all together: First apply txz, then tz, then r, then the inverse of tz, then the inverse of txz.
txz={{u/Sqrt[u^2 + v^2], v/Sqrt[u^2 + v^2], 0},{-v/Sqrt[u^2 + v^2], u/Sqrt[u^2 + v^2], 0},{0, 0, 1}};
tz={{w/Sqrt[u^2 + v^2 + w^2], 0, -Sqrt[u^2 + v^2]/Sqrt[u^2 + v^2 + w^2]},{0, 1, 0},{Sqrt[u^2 + v^2]/Sqrt[u^2 + v^2 + w^2], 0, w/Sqrt[u^2 + v^2 + w^2]}};
r={{Cos[q],-Sin[q],0},{Sin[q],Cos[q],0},{0,0,1}};
finalMatrix=Inverse[txz].Inverse[tz].r.tz.txz//FullSimplify;
output:
{{(u^2 + (v^2 + w^2) Cos[q])/(u^2 + v^2 + w^2), (
u v - u v Cos[q] - w Sqrt[u^2 + v^2 + w^2] Sin[q])/(
u^2 + v^2 + w^2), (
u w - u w Cos[q] + v Sqrt[u^2 + v^2 + w^2] Sin[q])/(
u^2 + v^2 + w^2)}, {(
u v - u v Cos[q] + w Sqrt[u^2 + v^2 + w^2] Sin[q])/(
u^2 + v^2 + w^2), (v^2 + (u^2 + w^2) Cos[q])/(u^2 + v^2 + w^2), (
v w - v w Cos[q] - u Sqrt[u^2 + v^2 + w^2] Sin[q])/(
u^2 + v^2 + w^2)}, {-((u w (-1 + Cos[q]))/(u^2 + v^2 + w^2)) - (
v Sin[q])/Sqrt[
u^2 + v^2 + w^2], -((v w (-1 + Cos[q]))/(u^2 + v^2 + w^2)) + (
u Sin[q])/Sqrt[u^2 + v^2 + w^2], (w^2 + (u^2 + v^2) Cos[q])/(
u^2 + v^2 + w^2)}}
Pretty ugly in text form (the matrix in 5.1 in the link), but that's the most useful for plugging it into a program. So anyways that one doesn't depend on the length of (u,v,w), so if that vector is A, you can just say A=d x e3, take R(A,q) (where I mean R is the rotation matrix found in the last code snippet, with (u,v,w)=A).
You just say, a'=R(A,q).a, with the . being matrix multiplication.

"I <3 u 2 bbz" - Dark Frager