It might make sense not to modify the equation formatting against the wishes of the original author, if the derivation is not clear. In a nutshell, it's the inversion of the rotation matrix multiplied by the basis vector. This is less clear once once simplifications take place, which is why I preferred the original version.

P.S. atan() still needs fixing.