Motion of a projectile in a rotated coordinate system, and converting equations to the new system Context: This in essence is explained on Mathematics of Classical & Quantum Physics by Byron & Fuller. This is from Section $1.4$, pages $12-13$.

So, suppose we launch a projectile (mass $m$) in the $x_1x_2$ plane, with initial velocity $\mathbf{v_0}$, at an angle of $\theta$ from the positive $x_1$-axis. We would like to consider the equations of motion in the $x_1'x_2'$ plane, which (to my understanding) should be formed by rotating the former coordinates (call them $K$) by $\theta$ to get a new set ($K'$). We keep things simple and only assume a downward force, $-mg$, per Newton's law.
The text communicates this situation with this diagram. (I believe there is a typo; it should be $x_2$ and $x_2'$ wherever $y_2$ and $y_2'$, respectively, are mentioned.)

To keep things brief, the text claims the following equations of motion, in the $K$ frame and the $K'$ frame respectively:
$$\begin{align*} \newcommand{\t}{\theta}
m \ddot x_1 = 0         &\xrightarrow{\text{rotate $K \to K'$}} m \ddot x_1' = -mg \sin \t \tag{1} \\
m \ddot x_2 = -mg       &\xrightarrow{\text{rotate $K \to K'$}} m \ddot x_2' = -mg \cos \t \tag{2}\\
x_1(0) = 0         &\xrightarrow{\text{rotate $K \to K'$}} x_1'(0) = 0 \tag{3} \\
x_2(0) = 0         &\xrightarrow{\text{rotate $K \to K'$}} x_2'(0) = 0 \tag{4} \\
\dot x_1(0) = v_0 \cos \t     &\xrightarrow{\text{rotate $K \to K'$}} \dot x_1'(0) = v_0 \tag{5} \\
\dot x_2(0) = v_0 \sin \t      &\xrightarrow{\text{rotate $K \to K'$}} \dot x_2'(0) = 0 \tag{6} \\
x_2 = \frac{-g}{2v_0^2 \cos^2 \t} x_1^2 + x_1 \tan \t  &\xrightarrow{\text{rotate $K \to K'$}} 
x_1' = x_2' \tan \t + v_0 \sqrt{ \frac{2 x_2'}{-g \cos \t}} \tag{7}
\end{align*}$$
My goal is to verify these. That is, I want to figure out how to convert from $K$ to $K'$, and then verify the above conversions.
I would think that the natural conversion is simply through a rotation matrix. As you'll recall, the matrix associated with rotating $\mathbb{R}^2$ by $\theta$ counterclockwise is
$$R = \begin{pmatrix}
\cos \t & -\sin \t \\
\sin \t & \cos \t \end{pmatrix}
\newcommand{\m}[1]{\begin{pmatrix} #1 \end{pmatrix}}$$
Hence, to verify $(1)$ and $(2)$, we would look at this calculation:
$$\begin{align*}\m{
\cos \t & -\sin \t \\
\sin \t & \cos \t}
\m{ \ddot x_1 \\ \ddot x_2} &= 
\m{
\cos \t & -\sin \t \\
\sin \t & \cos \t}
\m{ 0 \\ -g} \\
&= \m{g \sin \t \\ -g \cos \t}  
\end{align*}
$$
This does not give me $(\ddot x_1,\ddot x_2)^T$ however... Looking at $(3)$ and $(4)$ is trivial, so we'll ignore them; the subsequent pair, $(5)$ and $(6)$, give us
$$\begin{align*}\m{
\cos \t & -\sin \t \\
\sin \t & \cos \t}
\m{ \dot x_1(0) \\ \dot x_2(0) } &= 
\m{
\cos \t & -\sin \t \\
\sin \t & \cos \t}
\m{ v_0 \cos \t \\ v_0 \sin \t} \\
&=  \m{
v_0 \cos^2 \t - v_0 \sin^2 \t \\
v_0 \sin \t \cos \t + v_0 \sin \t \cos \t }
\end{align*}$$
again problematic.
What bugs me further is that if I tweak $R$ a bit, to get, say,
$$S = R^T = R^{-1}= \begin{pmatrix}
\cos \t & \sin \t \\
-\sin \t & \cos \t \end{pmatrix}$$
then something else happens. In $(5)$ and $(6)$, applying $S$ as the transformation $K \to K'$ gives
$$\begin{align*}\m{
\cos \t & \sin \t \\
-\sin \t & \cos \t}
\m{ \dot x_1(0) \\ \dot x_2(0) } &= 
\m{
\cos \t &  \sin \t \\
-\sin \t & \cos \t} 
\m{ v_0 \cos \t \\ v_0 \sin \t} \\ 
&=  \m{
v_0 \cos^2 \t + v_0 \sin^2 \t \\
-v_0 \sin \t \cos \t + v_0 \sin \t \cos \t } \\  
&=\m{
v_0  \\
0} \\
\end{align*}$$
as we'd expect! And if I look at $(1)$ and $(2)$ again, we get
$$\begin{align*}\m{
\cos \t & \sin \t \\
-\sin \t & \cos \t}
\m{ \ddot x_1 \\ \ddot x_2} &= 
\m{
\cos \t & \sin \t \\
-\sin \t & \cos \t}
\m{ 0 \\ -g} \\
&= \m{-g \sin \t \\ -g \cos \t}  
\end{align*}
$$

But this does not make any sense to me. $S$ corresponds to a clockwise rotation by $\t$, not counterclockwise. Why should $S$ be giving the correct answers?
Can anyone explain this strange discrepancy to me? The equations of motion also seem to be correct for what it's worth. (I also apologize in advance if it's a little too basic; physics is far from my forte.)
 A: The mathematical answer
Let $(\vec e_1,\vec e_2)$ be the basis of $\mathbb R^2$ corresponding to your frame of reference $K$, so that for some vector $\vec r$ with respect to $K$ it holds
$$
\vec r = r_1 \vec e_1 + r_2 \vec e_2 = \begin{pmatrix} r_1 \\ r_2 \end{pmatrix}~.
$$
Let further $\vec e_i' = R \vec e_i ~\forall i \in \{1,2\}$ with $R$ being your counter-clockwise rotation matrix, then clearly $(\vec e_1',\vec e_2')$ is the basis corresponding to $K'$.
Any vector $\vec r \in \mathbb R^2$ can be expressed in both bases,
$$
\vec r = r_1 \vec e_1 + r_2 \vec e_2 = r_1' \vec e_1' + r_2' \vec e_2'~,
$$
for the right choice of the coefficients $r_1,r_2,r_1',r_2'$, and what you want to do is calculate $r_1',r_2'$ given $r_1,r_2$:
$$
r_1' = r_1' \underbrace{\vec e_1'^T \vec e_1'}_{=1} + r_2' \underbrace{\vec e_1'^T \vec e_2'}_{=0} = \vec e_1'^T (r_1' \vec e_1' + r_2' \vec e_2') = \vec e_1^T R^T (r_1 \vec e_1 + r_2 \vec e_2) = \vec e_1^T R^{-1} \begin{pmatrix} r_1 \\ r_2 \end{pmatrix}~,
$$
$$
r_2' = r_1' \underbrace{\vec e_2'^T \vec e_1'}_{=0} + r_2' \underbrace{\vec e_2'^T \vec e_2'}_{=1} = \vec e_2'^T (r_1' \vec e_1' + r_2' \vec e_2') = \vec e_2^T R^T (r_1 \vec e_1 + r_2 \vec e_2) = \vec e_2^T R^{-1} \begin{pmatrix} r_1 \\ r_2 \end{pmatrix}~.
$$
$$
\Rightarrow \begin{pmatrix} r_1' \\ r_2' \end{pmatrix} = R^{-1} \begin{pmatrix} r_1 \\ r_2 \end{pmatrix}~.
$$
As you can see, by just manipulating the formalism the inverse matrix of $R$ appears quite naturally.
The intuitive answer
Instead of thinking about how to rotate the frame of reference $K$ so that it matches $K'$, you should think about how to make $K'$ match $K$: In your picture, $\vec v_0$ points in the $x'$-direction, so by rotating it clockwise by $\theta$, you can make it point in the $x$-diretion and then write it as $(|\vec v_0|,0)$, which agrees with your equations (5) and (6).
A: If you  rotate the gravity vector to $~S'~$
you obtain:
\begin{align*}
&\vec{g}'=\left[ \begin {array}{ccc} \cos \left( \theta \right) &\sin \left( 
\theta \right) &0\\  -\sin \left( \theta \right) &
\cos \left( \theta \right) &0\\  0&0&1\end {array}
 \right]\,\begin{bmatrix}
   0 \\
   -g \\
   0 \\
 \end{bmatrix}=-g\begin{bmatrix}
  \sin(\theta) \\
  \cos(\theta) \\
\end{bmatrix}
\end{align*}
from here
$$x'=v_0\,t+(\vec{g}')_x\,\frac{t^2}{2}=v_0\,t-g\,\sin(\theta)\,\frac{t^2}{2}\\
y'=+(\vec{g}')_y\,\frac{t^2}{2}=-g\,\cos(\theta)\,\frac{t^2}{2}$$
