# How does the rotation matrix exactly work?

I know that a rotation matrix is orthogonal and its determinant is 1. In `R³` there are basically 3 matrices that are responsible for rotation. Each matrix is for one axis.

Rotation Matrix on X-Axis:

``````1  0      0
0  cos α  -sin α
0  sin α  cos α
``````

Rotation Matrix on Y-Axis:

``````cos α   0  sin α
0       1  0
-sin α  0  cos α
``````

Rotation Matrix on Z-Axis:

``````cos α   -sin α   0
sin α   cos α    0
0       0        1
``````

Now, when we have a vector and want to rotate it by an angle α on an axis, you multiply the vector with one of the matrices described above. So if you want to rotate a vector on the Y and Z axis, you first multiply it with the rotation matrix for Y and the result of that with Z.

What I dont understand is how the `getRotationMatrix()` and `getRotationMatrixFromVector()` methods exactly work.

How can the rotation matrix that is passed to those methods have 9 OR 16 values? The matrices I described are 3x3 and for each axis there is one.

Also, if the float array of size 9 is passed to one of those methods, how can all axis be involved in this?

Could anyone please explain this to me in an easy and understandable way, since the documentation never explains that.