I just realized that I used a technique – projecting a vector on a line given by another vector – in my last post on ray-tracing that I did not justify in any way.
Look at this picture:
Given vector and
we are looking for vector
. We saw in the dot-product article, that we have
and of course
combining these we get
and therefore as
finally
which reduces to
in the case that is a unit-vector. This is the result we lacked.