I’m trying to solve the problem mentioned in the title, and the answer detailed here provides exactly what I was looking for: https://stackoverflow.com/a/3349134/4777480…except for the fact that the author skips several steps, leaving me confused as to how he ended up with the results he obtained!

For starters, there’s this line:

a = (r02 – r12 + d2 ) / (2 d)

Thankfully, a reply to the answer does clarify this one and I did verify it using the steps they detailed.

But leaves me with the last two steps…

How did we end up with this result?

P2 = P0 + a ( P1 – P0 ) / d

And how did that give us the intersection coordinates?

x3 = x2 +- h ( y1 – y0 ) / d

y3 = y2 -+ h ( x1 – x0 ) / d

A step-by-step explanation would be greatly appreciated, I want to understand the full process so I can implement it correctly in my code.

Source: Windows Questions C++