Tilting a line and a cloud of 3D points around the line I have a line defined by two points, $q_1$ and $q_2$, and a cloud of three-dimensional points around the line, $Q$. 
I rotate, but do not dilate/stretch the line by moving $q_1$ to some $t_1$ and $q_2$ to some $t_2$.  In other words, the Euclidean distance between $q_1$ and $q_2$, and between $t_1$ and $t_2$, is the same.  How do I correspondingly map the points to this new orientation s.t. their positions relative to the line remain unchanged?  
Note that the full set of equations for rotations about an arbitrary axis are provided here:
http://inside.mines.edu/~gmurray/ArbitraryAxisRotation/
For convenience, below I provide the Mathematica input for a rotation matrix about an arbitrary axis defined by points $P_1 = (a,b,c)$ & $P_2 = (d,e,f)$, with direction vector $<u,v,w> = (d-a,e-b,f-c)$, where "theta" = $\theta$ is the rotation angle (in radians), and where $L = (u^2+v^2+w^2)$.  The three-dimensional point to be rotated is given by $(x,y,z)$.    
RotationMatrixArbitraryLine = 
{((a*(v^2 + w^2) - u*(b*v + c*w - u*x - v*y - w*z))*(1 -
          Cos[theta]) + L*x*Cos[theta] + 
      L^(1/2)*(-c*v + b*w - w*y + v*z)Sin[theta])/
    L, ((b(u^2 + w^2) - v*(a*u + c*w - u*x - v*y - w*z))*(1 - 
         Cos[theta]) + L*y*Cos[theta] + 
      L^(1/2)*(c*u - a*w + w*x - u*z)Sin[theta])/
    L, ((c(u^2 + v^2) - w*(a*u + b*v - u*x - v*y - w*z))*(1 - 
         Cos[theta]) + L*z*Cos[theta] + 
      L^(1/2)*(-b*u + a*v - v*x + u*y)*Sin[theta])/L}
The above expression works on the tests I have provided.  For example, a $\theta = \frac{\pi}{4}$ degree rotation of the point {0,0,1} about direction vector {1,0,0} maps the point to {0,-1,0}.  Changing the direction vector to {0,1,0} maps the same point to {1,0,0}.
 A: You are looking for a linear (or affine) isometry which maps $q_1$ to $t_1$ and $q_2$ to $t_2$. 
First map $q_1$ to $t_1$. This gives a translation $x\mapsto x + t_1 - q_1$. call this map $T$. 
Then the vector $q_2-q_1$ is mapped to $t_2-t_1$. This will be a rotation, which we compute in the following steps -


*

*The vector $u=(q_2-q_1)\times(t_2-t_1)$ (cross product) is perpendicular to the plane spanned by these vectors. Consider $a$ to be the corresponding unit vector. Also let $b$ and $c'$ be the unit vectors in the directions $q_2-q_1$ and $t_2-t_1$. Clearly $a$, $b$ and $c=a\times b$ are a set of orthonormal vectors. We use this basis in place of usual $k$, $i$ and $j$ (note the order). 

*let us say the angle between $q_2-q_1$ and $t_2-t_1$ is $\theta$. We want to rotate the plane spanned by $b$ and $c$ such that $b$ is rotated towards $c$   by an angle $\theta$. [draw a diagram and the various orientations will be clear]

*for any vector $x$, its components along $a$, $b$ & $c$ are $(x.a)a$, $(x.b)b$  & $(x.c)c$. So we can write $$x=\left(\begin{array}{c}x.a\\x.b\\x.c\\\end{array}\right)$$ To write the rotation map we observe that in our chosen basis $$\left(\begin{array}{c}1\\0\\0\\\end{array}\right)\mapsto \left(\begin{array}{c}1\\0\\0\\\end{array}\right)$$ $$\left(\begin{array}{c}0\\1\\0\\\end{array}\right)\mapsto \left(\begin{array}{c}0\\\cos\theta\\\sin\theta\\\end{array}\right)$$ $$\left(\begin{array}{c}1\\0\\0\\\end{array}\right)\mapsto \left(\begin{array}{c}0\\-\sin\theta\\\cos\theta\\\end{array}\right)$$ Write the matrix of that map, call it $M$. I leave that as an exercise.

*Now I will write the final rotation map $R$ - $$x\mapsto M(x-t_1)+t_1$$ Where every vector is expressed in our chosen basis. [Work out this final expression as one more exercise]


The final affine map is given by the composition of the two maps translation $T$ followed by rotation $R$. This is not unique. There could be many more maps which will do your job.
