I am trying to learn about rotation matrices, but when watching tutorials on youtube and even looking at rotation matrix questions on stack exchange I see two different matrices used as general rotation matrices. They look like this:
$$\left[ \ \cos\theta \quad -\sin\theta \\ \sin\theta \quad \cos\theta \ \right]$$
$$\left[ \ \cos\theta \quad \sin\theta \\ -\sin\theta \quad \cos\theta \ \right]$$
I would like to understand why they are both used to describe a general 2D rotation. The youtube videos I have watched do not mention the existence of another format. In my textbook (Modern Robotics), they state that the vector end results (after rotation matrix has been applied) should be
$$ \hat x = \cos\theta \hat x + \sin\theta \hat y $$ $$ \hat y = -\sin\theta \hat x + \cos\theta \hat y $$
which suggests the first format, but then states that the generalized format would be the second example, which is even more confusing. Please advise.
As a general convention, the columns of a rotation matrix describe the directions of a local coordinate system as seen from the inertial coordinate system.
$${\rm R}=\left[\begin{array}{c|c} \hat{u} & \hat{v}\end{array}\right]=\left[\begin{array}{c|c} \cos\varphi & \mbox{-}\sin\varphi\\ \sin\varphi & \cos\varphi \end{array}\right]$$
where $\hat{u}$ designates the local x-axis, and $\hat{v}$ the local y-axis.
The other matrix mentioned is the inverse of the rotation matrix, which happens to equal the transpose of the matrix.
$${\rm R}^{-1}={\rm R}^{\top}$$
Now ask yourself. How much of the red $\hat{u}$ axis vector rests on the global x-axis, and how much on the global y-axis. The answer by inspection of the above sketch is
$$ \hat{u} = \pmatrix{ \cos \theta \\ \sin \theta} $$
Similarly for the blue $\hat{v}$ axis vector
$$ \hat{v} = \pmatrix{ \mbox{-}\sin \theta \\ \cos \theta} $$
and the column combination ${\rm R}=\left[\begin{array}{c|c} \hat{u} & \hat{v}\end{array}\right]$ is the rotation matrix.
For any vector $(a,b)$ described in the local coordinates, the transformation to the global coordinates is done with linear algebra as
$$\begin{pmatrix}x\\ y \end{pmatrix}=\left[\begin{array}{c|c} \cos\theta & \mbox{-}\sin\theta\\ \sin\theta & \cos\theta \end{array}\right]\begin{pmatrix}a\\ b \end{pmatrix}=\begin{pmatrix}a\cos\theta\ - b\sin\theta\\ a\sin\theta+b\cos\theta \end{pmatrix}$$
but also can be interpreted in terms of vector algebra as
$$\vec{r}=a\hat{u}+b\hat{v}=\left(a\cos\theta - b\sin\theta\right)\hat{i} + \left(a\sin\theta + b\cos\theta\right)\hat{j}$$
since
$$\begin{aligned}a\,\hat{u} & =a\cos\theta\hat{i}+a\sin\theta\hat{j}\\ b\,\hat{v} & =\mbox{-}b\sin\theta\hat{i}+b\cos\theta\hat{j} \end{aligned}$$