# The camera rotation matrix

Hi,

I'm new to jME and is trying out the beginner tutorials. Now I'm on tutorial 12 - Hello LevelOfDetail. I think I got most of it but last few bits - the camera rotations. The code is as follows:

// Left vector

tempMa.setColumn(0, up.cross(lookAtObject, tempVc).normalizeLocal());

// Up vector

tempMa.setColumn(1, left.cross(lookAtObject, tempVd).normalizeLocal());

// Direction vector

tempMa.setColumn(2, lookAtObject);

cn.setLocalRotation(tempMa);

You can reach the tutorial by the link http://www.jmonkeyengine.com/wiki/doku.php/starter:hello_lod and it's at the bottom of the page. Honestly, I don't quite understand those bits of things so here is my question:

1. Which axis or vector does the camera rotate to?
2. Why the matrix is caculated in such a way?

I know I'm not very good at math, so please just point me in the right directions where I should start to look at if it's too basic. Sorry if the question is stupid or it's asked before. Thanks for any help.

Thanks so much for your excellent explanation. Now I think I know what all it's doing. It turned out that I was thinking the wrong way that I misinterpreted the behavior of the method setLocalRotation. I thought the camera was rotating along something but it is just simply placing the camera towards the maggie object all the way along moving the path. once we have the 'lookAtObject' direction we simply to caculate the other two vectors that were originally pointing to Up and Left to eventually make up of the matrix.

Regarding the question on which direction does the new vector point to after a cross product, I think the direction is not ambiguous but determined by the directions of the two vectors that were doing the cross product. Suppose we have two vector a and b right on your monitor and then we connect a's head to b's tail. We can tell the direction of a cross product b by determining the direction of a to b. If a to b shows a clockwise direction in a left hand cooridination system, a cross product b points to you. If a to b shows an anti-clockwise direction, it points away from you and it's doing in the reverse way in a right hand cooridination system.