I'm really new to all of this and I'm 13 learning OpenGL. So I was writing a rotation function (3D) for an OpenGL project and I encountered a couple websites that claim that if I multiply the rotation matrix by a vector I would get the correct result. To do this I got the matrix that I was going to rotate and 'translated' its information into a vector. e.g $$ \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 4 & 0 & 0\\ 0 & 0 & 2 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix}\rightarrow \begin{bmatrix} 1 & 4 & 2 & 1 \end{bmatrix}. $$ After that I would multiply the rotation matrix by the vector and it did not work as intended. After this, I simply multiplied the Original Matrix by the Rotation Matrix and it worked as intended. Could I get an explanation on why this would happen when the vector has the same information as the original matrix?
Example: $$ \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & cos(45) & sin(45) & 0\\ 0 & -sin(45) & cos(45) & 0\\ 0 & 0 & 0 & 1 \end{bmatrix}* \begin{bmatrix} 0 & 4 & 1 & 1\\ \end{bmatrix} $$ $$ \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 4 & 0 & 0\\ 0 & 0 & 2 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix}* \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & cos(45) & sin(45) & 0\\ 0 & -sin(45) & cos(45) & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} $$
Thanks.
Edit: After I finished multiplying the Matrix and the Vector (which I got a vector for the answer) I tried to convert it back to its old matrix form. e.g Matrix[0][0] = Vector[0]
There’s no reason (that I know) why the two computations should give the same answer. In fact, the two computations don’t even give the same kind of result: the matrix-times-vector computation gives a vector result, and the matrix-times-matrix one gives a matrix.
Even if you convert your vector result back to a matrix (as in your edited question), there’s still no reason to expect the same results.
Just because two computations involve the same numbers, you shouldn’t expect them to give you the same results. After all, the computations “2+3” and “2*3” both involve 2 and 3, but they obviously don’t give the same result.
To transform points and vectors in OpenGL, you need to multiply them by matrices, not by vectors.