# camera rotation matrix calculation

i`m trying to calculate the matrix for camera rotation rotation around the 0-X axes: { 1, 0, 0 0, cosX, -sinX, 0, sinX, cosX} rotation around the 0-Y axes: {cosY, 0, sinY, 0, 1, 0, -sinY 0, cosY} rotation around the 0-Z axes: {cosZ, -sinZ, 0 sinZ, cosZ, 0 0, 0, 0} after multiplication of the matricies we`ll yield the matrix, which rotates the camera around the global X,Y,Z axes:
matrix[0]=cosYcosZ; matrix[4]=-cosYsinZ; matrix[8]=sinY; matrix[12]=0;
matrix[1]=sinXsinYcosZ+cosXsinZ; matrix[5]=-sinXsinYsinZ+cosXcosZ; matrix[9]=-sinXcosY; matrix[13]=0;
matrix[2]=-cosX
sinYcosZ+sinXsinZ; matrix[6]=cosXsinYsinZ+sinXcosZ; matrix[10]=cosXcosY; matrix[14]=0;
matrix[3]=0; matrix[7]=0;matrix[11]=0; matrix[15]=1;

To manipulate the camera - we have 2 angles: x, y cordinates of the mouse - turn around the Y and X axes.
This two angles - LOCAL to camera.(if global Y-not zero than global X not zero and global Z not zero).
Local camera 0Z axes always lies in global X0Z coordinates

How to project this 2 local mouse angles on to 3 global angles?

in a 3-dimensional enviroment you have 6 degrees of freedom, 3 along your axis and 3 rotating around your axis.
In a 2-dimensional enviroment you have 2 degrees of freedom, 2 along your axis.

A mouse only covers a dimensional enviroment, up/down and left/right. So if you want to add more you have to use the mouse buttons, which are adding 2 extra degrees for each one pressed.
e.g
none pressed
up/down–>movement along y-axis
left/right–>movement along x-axis

left pressed
up/down–>turn around y-axis
left/right–>turn around x-axis

right pressed

up/down–>move along z-axis
left/right–>turn around z-axis

an other possibility is using a spacemouse which can handle all 6 degrees

hope that helps
Chris

oops didn’t think of course u can rotate in 2-dimensional enviroment, that would give you 3 degrees of freedom in a 2D enviroment, but a mouse can’t register rotation so it is still like i said…