Oriented cylinder equation I am interested in finding the equation of the intersection of a ray with an arbitrarily oriented cylinder. I found this related topic that explains how the equation of an arbitrarily oriented cylinder is found. The topic also links an article that shows how to solve the intersection given the oriented cylinder equation.
The aforementioned topic explains really well the concepts and how the oriented cylinder equation is found. Now I need to plug in the equation of a ray in the equation in order to find the intersection between the ray and the cylinder.
I wanted to rewrite and develop all the equations to really understand how things worked. So I have the oriented cylinder equation
$$
(q - pa - \langle q - pa, va \rangle va)^2 = r^2
$$
Then, the same equation where $q$ is replaced by the ray equation $P(t) = p + \vec{v}t$ and with $\Delta p = p - pa$
$$
(\Delta p + vt - \langle va, \Delta p + vt \rangle va)^2 - r^2 = 0
$$
So far, it is the exact same equation as in the article. In order to find the intersection, I have to develop the equation and solve the resulting polynomial of the form $ax^2 + bx + c = 0$
This is where I need a bit of help. I have developed the equation (see the appendix below) and I have values for $a, b$ and $c$ of the polynomial. The problem is with the $b$ component. The article gives:
$$
b = 2 \langle v - \langle va, v \rangle va, \Delta p - \langle \Delta p, va \rangle va \rangle \\
$$
But from my development I have the following value for $b$ and cannot factorize it to retrieve the same value expressed above.
$$
b = 2\Delta pv - 2\Delta p \langle va, v \rangle va - 2v\langle va, \Delta p \rangle va + 2va \langle va, \Delta p \rangle va \langle va, v \rangle
$$
Factorizing for $a$ and $c$ is relatively simple with remarkable identities but I cannot figure out how to do this for $b$. Maybe some things simplify when reasonning about the dot product of the vectors, if they are orthogonal for instance but once again I don't find out how.
I would like someone to explain how I can retrieve the exact same $b$ value shown in the article (and explain the thought process of course).
Thanks !
Appendix: development of the equation
It is possible that some mistakes have been made either when doing the development or when rewriting the equations here.
$$
\begin{align*}
&(\Delta p + vt - \langle va, \Delta p + vt \rangle va)^2 - r^2 = 0
\\
&\Leftrightarrow (\Delta p + vt)^2 - 2(\Delta p + vt)\langle va, \Delta p + vt \rangle va + (\langle va, \Delta p + vt \rangle va)^2 - r^2 = 0
\\
&\Leftrightarrow \Delta p^2 + 2 \Delta p vt + (vt)^2 -
(2 \Delta p + 2vt)(\langle va, \Delta p \rangle va + t \langle va, v \rangle va) +
((\langle va, \Delta p \rangle + t \langle va, v \rangle)va)^2 - r^2 = 0
\\
&\Leftrightarrow \Delta p^2 + 2\Delta pvt + (vt)^2 -
(2\Delta p \langle va, \Delta p \rangle va + 2\Delta pt \langle va, v \rangle va + 2vt \langle va , \Delta p \rangle va + 2vt^2 \langle va, v \rangle va) +
(va \langle va, \Delta p \rangle)^2 + 2va\langle va, \Delta p \rangle vat\langle va, v \rangle + (vat \langle va v \rangle)^2 - r^2 = 0
\\
&\Leftrightarrow \Delta p^2 + 2\Delta pvt + v^2t^2 - 2\Delta p \langle va, \Delta p \rangle va - 2\Delta pt \langle va, v \rangle va - 
2vt\langle va, \Delta p \rangle va - 2vt^2\langle va, v \rangle va + va^2\langle va, \Delta p \rangle^2 +
2va\langle va, \Delta p \rangle vat \langle va, v \rangle + va^2t^2 \langle va, v \rangle^2 - r^2 = 0
\\
&\Leftrightarrow t^2(v^2 - 2v\langle va, v \rangle va + va^2 \langle va, v \rangle^2) +
t(2\Delta pv - 2\Delta p \langle va, v \rangle va - 2v\langle va, \Delta p \rangle va + 2va \langle va, \Delta p \rangle va \langle va, v \rangle) +
\Delta p^2 - 2\Delta p \langle va, \Delta p \rangle va + va^2 \langle va, \Delta p \rangle^2 - r^2 = 0
\\
&\Leftrightarrow t^2(v - \langle va, v \rangle va)^2 +
t(2\Delta pv - 2\Delta p \langle va, v \rangle va - 2v\langle va, \Delta p \rangle va + 2va \langle va, \Delta p \rangle va \langle va, v \rangle) +
(\Delta p - \langle va, \Delta p \rangle va)^2 - r^2 = 0
\end{align*}
$$
If someone know how to align the equations that would be great :)
 A: You say that you have
$$
b = 2\Delta pv - 2\Delta p \langle va, v \rangle va - 2v\langle va, \Delta p \rangle va + 2va \langle va, \Delta p \rangle va \langle va, v \rangle,
$$
but that first term is a product of two vectors. Should
$
2\Delta pv$
actually be $
\langle 2\Delta p, v \rangle$? Similar question for the next few terms as well. If so, what you have is actually
$$
b = 2 \langle \Delta p, v \rangle - 2 \langle \Delta p, \langle va, v \rangle va \rangle - 2 \langle v, \langle va, \Delta p \rangle va \rangle + 2 \langle va, \langle va \Delta p \rangle va,  \langle va, v \rangle \rangle,
$$
I'm going to write $Q$ for $\langle va, v \rangle$ and $R$ for $\langle va, \Delta p \rangle$, so that what you have is now:
$$
b = 2 \langle \Delta p, v \rangle - 2 \langle \Delta p, Q va \rangle - 2 \langle v, R va \rangle + 2 \langle va R,  va Q \rangle.
$$
And pulling constants out of the inner products, that's
$$
b/2 =  \langle \Delta p, v \rangle - Q \langle \Delta p,  va \rangle -  R\langle v,  va \rangle + QR \langle va ,  va  \rangle.
$$
That's not so bad. Let's gather terms that start with $\Delta p$:
\begin{align}
b/2 
& =  \langle \Delta p, v \rangle - Q \langle \Delta p,  va \rangle -  R\langle v,  va \rangle + QR \langle va ,  va  \rangle\\
& =  \langle \Delta p, v  - Q  va \rangle -  R\langle v,  va \rangle + QR \langle va ,  va  \rangle\\
& =  \langle \Delta p, v  - Q  va \rangle -  R\bigl( \langle v,  va \rangle - Q \langle va ,  va  \rangle \bigr)\\
& =  \langle \Delta p, v  - Q  va \rangle -  R\bigl( \langle v - Q  va ,  va  \rangle \bigr)\\
& =  \langle \Delta p - Rva, v  - Q  va \rangle \\
\end{align}
which is exactly (once you substitute back for $Q$ and $R$) the goal you had.
