The following matrix is the two dimensional Givens Rotation from the $x$ axis to the $y$ axis:

$\begin{array}{c}\left(\begin{array}{cc}\mathrm{cos}\left(\theta \right)& \mathrm{cos}\left(\theta +90°\right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{sin}\left(\theta +90°\right)\end{array}\right)\\ \left(\begin{array}{cc}\mathrm{cos}\left(\theta \right)& \mathrm{cos}\left(\theta +\frac{\pi }{2}\right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{sin}\left(\theta +\frac{\pi }{2}\right)\end{array}\right)\\ \left(\begin{array}{cc}\mathrm{cos}\left(\theta \right)& -\mathrm{sin}\left(\theta \right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{cos}\left(\theta \right)\end{array}\right)\end{array}$

This matrix rotates two dimensional column vectors about the origin of the $x$ - $y$ plane.

For instance, if we rotate the unit column vector $\left(1,0\right)$ using this Givens Rotation, then we have:

$\begin{array}{c}\left(\begin{array}{cc}\mathrm{cos}\left(\theta \right)& \mathrm{cos}\left(\theta +90°\right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{sin}\left(\theta +90°\right)\end{array}\right)\left(\begin{array}{c}1\\ 0\end{array}\right)\\ \left(\begin{array}{cc}\mathrm{cos}\left(\theta \right)& \mathrm{cos}\left(\theta +\frac{\pi }{2}\right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{sin}\left(\theta +\frac{\pi }{2}\right)\end{array}\right)\left(\begin{array}{c}1\\ 0\end{array}\right)\\ \left(\begin{array}{cc}\mathrm{cos}\left(\theta \right)& -\mathrm{sin}\left(\theta \right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{cos}\left(\theta \right)\end{array}\right)\left(\begin{array}{c}1\\ 0\end{array}\right)\\ \left(\begin{array}{c}\mathrm{cos}\left(\theta \right)\\ \mathrm{sin}\left(\theta \right)\end{array}\right)\end{array}$

Therefore, if we rotate the column vector $\left(x,y\right)$, then we have:

$\begin{array}{c}\left(\begin{array}{cc}\mathrm{cos}\left(\theta \right)& \mathrm{cos}\left(\theta +90°\right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{sin}\left(\theta +90°\right)\end{array}\right)\left(\begin{array}{c}x\\ y\end{array}\right)\\ \left(\begin{array}{cc}\mathrm{cos}\left(\theta \right)& \mathrm{cos}\left(\theta +\frac{\pi }{2}\right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{sin}\left(\theta +\frac{\pi }{2}\right)\end{array}\right)\left(\begin{array}{c}x\\ y\end{array}\right)\\ \left(\begin{array}{cc}\mathrm{cos}\left(\theta \right)& -\mathrm{sin}\left(\theta \right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{cos}\left(\theta \right)\end{array}\right)\left(\begin{array}{c}x\\ y\end{array}\right)\\ \left(\begin{array}{c}x\mathrm{cos}\left(\theta \right)-y\mathrm{sin}\left(\theta \right)\\ x\mathrm{sin}\left(\theta \right)+y\mathrm{cos}\left(\theta \right)\end{array}\right)\end{array}$

and to rotate that column vector $\left(x,y\right)$ back to the $x$ axis so that the $y$ value is zero, we would have:

$\begin{array}{c}\left(\begin{array}{cc}\mathrm{cos}\left(\theta \right)& \mathrm{cos}\left(\theta +90°\right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{sin}\left(\theta +90°\right)\end{array}\right)\left(\begin{array}{c}x\\ y\end{array}\right)=\left(\begin{array}{c}{x}^{\prime }\\ 0\end{array}\right)\\ \left(\begin{array}{cc}\mathrm{cos}\left(\theta \right)& \mathrm{cos}\left(\theta +\frac{\pi }{2}\right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{sin}\left(\theta +\frac{\pi }{2}\right)\end{array}\right)\left(\begin{array}{c}x\\ y\end{array}\right)=\left(\begin{array}{c}{x}^{\prime }\\ 0\end{array}\right)\\ \left(\begin{array}{cc}\mathrm{cos}\left(\theta \right)& -\mathrm{sin}\left(\theta \right)\\ \mathrm{sin}\left(\theta \right)& \mathrm{cos}\left(\theta \right)\end{array}\right)\left(\begin{array}{c}x\\ y\end{array}\right)=\left(\begin{array}{c}{x}^{\prime }\\ 0\end{array}\right)\\ \left(\begin{array}{c}x\mathrm{cos}\left(\theta \right)-y\mathrm{sin}\left(\theta \right)\\ x\mathrm{sin}\left(\theta \right)+y\mathrm{cos}\left(\theta \right)\end{array}\right)=\left(\begin{array}{c}{x}^{\prime }\\ 0\end{array}\right)\end{array}$

So, we need to use an angle $\theta$ such that the $y$ value goes to zero.  Let’s concentrate on that lower equation:

$\begin{array}{c}x\mathrm{sin}\left(\theta \right)+y\mathrm{cos}\left(\theta \right)=0\\ x\mathrm{sin}\left(\theta \right)=-y\mathrm{cos}\left(\theta \right)\\ \frac{\mathrm{sin}\left(\theta \right)}{\mathrm{cos}\left(\theta \right)}=-\frac{y}{x}\\ \mathrm{tan}\left(\theta \right)=-\frac{y}{x}\\ \theta =\mathrm{arctan}\left(-\frac{y}{x}\right)\\ \theta =-\mathrm{arctan}\left(\frac{y}{x}\right)\end{array}$

Remember: $\mathrm{arctan}\left(\frac{y}{x}\right)$ is atan2( y, x ) in C/C++ and ArcTan[ x, y ] in Mathematica.

Therefore, when we rotate the column vector $\left(x,y\right)$ back to the $x$ axis so that the $y$ value is zero, we have:

$\begin{array}{c}\left(\begin{array}{cc}\mathrm{cos}\left(-\mathrm{arctan}\left(\frac{y}{x}\right)\right)& \mathrm{cos}\left(-\mathrm{arctan}\left(\frac{y}{x}\right)+90°\right)\\ \mathrm{sin}\left(-\mathrm{arctan}\left(\frac{y}{x}\right)\right)& \mathrm{sin}\left(-\mathrm{arctan}\left(\frac{y}{x}\right)+90°\right)\end{array}\right)\left(\begin{array}{c}x\\ y\end{array}\right)\\ \left(\begin{array}{cc}\mathrm{cos}\left(-\mathrm{arctan}\left(\frac{y}{x}\right)\right)& \mathrm{cos}\left(-\mathrm{arctan}\left(\frac{y}{x}\right)+\frac{\pi }{2}\right)\\ \mathrm{sin}\left(-\mathrm{arctan}\left(\frac{y}{x}\right)\right)& \mathrm{sin}\left(-\mathrm{arctan}\left(\frac{y}{x}\right)+\frac{\pi }{2}\right)\end{array}\right)\left(\begin{array}{c}x\\ y\end{array}\right)\\ \left(\begin{array}{cc}\mathrm{cos}\left(-\mathrm{arctan}\left(\frac{y}{x}\right)\right)& -\mathrm{sin}\left(-\mathrm{arctan}\left(\frac{y}{x}\right)\right)\\ \mathrm{sin}\left(-\mathrm{arctan}\left(\frac{y}{x}\right)\right)& \mathrm{cos}\left(-\mathrm{arctan}\left(\frac{y}{x}\right)\right)\end{array}\right)\left(\begin{array}{c}x\\ y\end{array}\right)\\ \left(\begin{array}{cc}\frac{x}{\sqrt{{x}^{2}+{y}^{2}}}& -\left(-\frac{y}{\sqrt{{x}^{2}+{y}^{2}}}\right)\\ -\frac{y}{\sqrt{{x}^{2}+{y}^{2}}}& \frac{x}{\sqrt{{x}^{2}+{y}^{2}}}\end{array}\right)\left(\begin{array}{c}x\\ y\end{array}\right)\\ \left(\begin{array}{c}\frac{{x}^{2}}{\sqrt{{x}^{2}+{y}^{2}}}+\frac{{y}^{2}}{\sqrt{{x}^{2}+{y}^{2}}}\\ -\frac{xy}{\sqrt{{x}^{2}+{y}^{2}}}+\frac{xy}{\sqrt{{x}^{2}+{y}^{2}}}\end{array}\right)\\ \left(\begin{array}{c}\frac{{x}^{2}+{y}^{2}}{\sqrt{{x}^{2}+{y}^{2}}}\\ 0\end{array}\right)\\ \left(\begin{array}{c}\sqrt{{x}^{2}+{y}^{2}}\\ 0\end{array}\right)\end{array}$

Since the radius $r$ from the origin to the column vector $\left(x,y\right)$ is $\sqrt{{x}^{2}+{y}^{2}}$ (also known as the norm), then we also have:

$\begin{array}{c}\left(\begin{array}{c}\sqrt{{x}^{2}+{y}^{2}}\\ 0\end{array}\right)\\ \left(\begin{array}{c}r\\ 0\end{array}\right)\end{array}$