Linear transformation in 3D graphics can be tricky, here is as “Matrix Cycle” that should help to better understand transition between spaces. The tricky part is actual numerical representation (or direction) in the transformation matrix. Some info about also here (nice notation of actual numerical matrix direction) nice online demo here

following picture is from :http://antongerdelan.net/opengl/raycasting.html