It took me long time to find a good formula to calculate the confined angle between two $2D$-vectors for example $(u,v)$. I have found the following formula:
$θ=2\operatorname{atan2}\left(\bigl\| \|v\|u−\|u\|v \bigr\|, \bigl\| \|v\|u+\|u\|v \bigr\|\right)$
where $\|u\|$ and $\|v\|$ are the length of the vector $u$ and $v$ respectively. AS we know:
$\cos(x)= \text{adjacent/hypotenuse}$
$\sin(x) = \text{opposite/hypotenuse}$
$\tan(x) = \text{adjacent/adjacent}$
So how can one interpret $\operatorname{atan2}\left(\bigl\| \|v\|u−\|u\|v \bigr\|, \bigl\| \|v\|u+\|u\|v \bigr\|\right)$ function in calculating the confined angle?
That looks horribly complicated, and all those norms can't be cheap to compute. What I'd do given vectors $u=(x_1,y_1)$ and $v=(x_2,y_2)$ is first consider the matrix $$ \begin{pmatrix} x_1 & y_1 \\ -y_1 & x_1 \end{pmatrix} $$ which is a combination of a scaling by $|u|$ (which for the purpose of angles we can ignore) and a rotation matrix that rotates $u$ down to the positive $x$-axis. Therefore, $$ \begin{pmatrix} x_1 & y_1 \\ -y_1 & x_1 \end{pmatrix} \begin{pmatrix} x_2 \\ y_2 \end{pmatrix} = \begin{pmatrix} x_1x_2 + y_1y_2 \\ x_1y_2 - x_2y_1 \end{pmatrix} $$ has the same angle with the $x$-axis as $v$ has to $u$, and you can then compute this angle as $$ \operatorname{atan2}(x_1x_2 + y_1y_2, x_1y_2 - x_2y_1 ) $$ (or the other way around, depending on your programming languages's conventions for the order of the arguments to atan2).