What equation describes a cylinder with two points $A(X_1, Y_1, Z_1),B(X_2 ,Y_2, Z_2)$ and radius $R$? I want to determine the equation that describes a cylinder, given two points $A(X_1,  Y_1,Z_1),B(X_2 ,Y_2, Z_2)$ on its surface, and the cylinder radius R?

 A: Let $A(x_1, y_1, z_1) , B (x_2, y_2, z_2) $ be two points on the cylinder, which has a known radius $r$.  The algebraic equation of the cylinder is
$ \mathbf{p}^T (I - \mathbf{a a}^T ) \mathbf{p} = r^2 $
where $\mathbf{p}$ is any point on the cylinder, and $\mathbf{a}$ is a unit vector along the axis of the cylinder that is assumed to pass through the origin.
Re-arranging,
$ A^T \mathbf{a a}^T A = A^T A - r^2 $
$ B^T \mathbf{a a}^T B = B^T B - r^2 $
The above two equations can also be written as
$ \mathbf{a}^T A A^T \mathbf{a} = A^T A - r^2 $
$ \mathbf{a}^T B B^T \mathbf{a} = B^T B - r^2 $
Now, since $\mathbf{a}$ is a unit vector, then
$ \mathbf{a}^T A = A^T \mathbf{a} = \| A \| \cos(\theta) $
where $\theta$ is the angle between $\mathbf{a}$ and $A$. Therefore, the equations become
$ \| A \|^2 \sin^2 (\theta) = r^2 $
and
$ \| B \|^2 \sin^2( \phi) = r^2 $
Since $A, B, r$ are known, then we use the above two equations to find $\theta$ and $\phi$ (where $\phi$ is the angle between $B$ and $\mathbf{a} $).
So now the problem of finding the vector $\mathbf{a}$ becomes that of finding the intersection of two cones whose axes are the vectors $A$ and $B$, and whose semi-vertical angles are $ \theta $ and $\phi$.  And this problem has a well-known solution.
See here for full details.
