Cylinder-ray intersections equation I found an article involving infinite cylinder-ray intersections, and I don't know how they develop this equation:
$$(q - p_a - (v_a, q - p_a)v_a)^2 - r^2 = 0$$
In the end of the first page I quote:

Infinite cylinder along $y$-axis of radius $r$ has equation
  $x^2 + z^2 - r^2 = 0$.
  The equation for a more general
  cylinder of radius $r$ oriented along
  a line $p_a + v_at$:
$(q - p_a - (v_a, q - p_a)v_a)^2 - r^2 = 0$
  where $q = (x,y,z)$ is a point on the cylinder.

 A: This can all be made to work under the assumption that $v_a$ is a unit vector, and I doubt it holds unless such is the case; so I assume $\Vert v_a \Vert = 1$.  Furthermore, having glanced at the linked PDF, and edited the equation (which is now) $(q-p_a-(v_a,q-p_a)v_a)^2-r^2=0$ accordingly, I think an explanation may be forthcoming:
For any $q$ in the cylinder, the vector $(v_a,q-p_a)v_a$ is the projection of $q - p_a$ onto the one-dimensional subspace generated by the unit vector $v_a$.  The vector $q-p_a-(v_a,q-p_a)v_a$ is thus orthogonal to $v_a$; indeed, we have 
$(v_a, q-p_a-(v_a,q-p_a)v_a) = (v_a, q - p_a) - (v_a, q - p_a)(v_a, v_a)$
$= (v_a, q - p_a) -  (v_a, q - p_a) = 0 \tag{1}$
since $(v_a, v_a) = \Vert v_a \Vert^2 = 1$.  Now consider the triangle of vectors formed by the points $p_a, \, p_a + (v_a, q - p_a)v_a, \, q$; the sides of this triangle may be taken to be $q - p_a$, $p_a + (v_a, q - p_a)v_a - p_a = (v_a, q - p_a)v_a$, and $q - (p_a + (v_a, q - p_a)v_a) = q - p_a - (v_a, q - p_a)v_a$.  Furthermore, $q - p_a = q - p_a - (v_a, q - p_a)v_a + (v_a, q - p_a)v_a$, and since as we have seen $q - p_a - (v_a, q - p_a)v_a$ is orthogonal to $v_a$, it is likewise orthogonal to $(v_a, q - p_a)v_a$.  Thus $q - p_a - (v_a, q - p_a)v_a$ and $(v_a, q - p_a)v_a$ form two sides of a (vector) right triangle, the hypoteneuse of which is $q - p_a$, since it is opposite the right angle between $q - p_a - (v_a, q - p_a)v_a$, $(v_a, q - p_a)v_a$.  Since $q - p_a - (v_a, q - p_a)v_a$ is normal to the line $p_a + tv_a$, and as a vector it extends from the point  $p_a + (v_a, q - p_a)v_a$ to $q$, its magnitude must equal the normal distance between $q$ and the line $p_a + tv_a$, which is $r$, the radius of the cylinder.  Therefore $q$ satisfies the equation
$(q-p_a-(v_a,q-p_a)v_a)^2-r^2=0. \tag{2}$
Hope this helps.  Cheerio,
and as always, 
Fiat Lux!!!
