I need to calculate the angle between two 3D vectors. There are plenty of examples available of how to do that but the result is always in the range $0-\pi$. I need a result in the range $\pi-2\pi$.
Let's say that $\vec x$ is a vector in the positive x-direction and $\vec y$ is a vector in the positive y-direction and $\vec z$ is a reference vector in the positive z-direction. $\vec z$ is perpendicular to both $\vec x$ and $\vec y$. Would it then be possible to calculate the angle between $\vec x$ and $\vec y$ and get a result in the range $\pi-2\pi$?
The angle value should be measured counter clockwise. I have not been able to figure out how to do that. I am no math guru but I have basic understanding of vectors at least. Thank you very much for the help!
You need to define a perpendicular axis first. Otherwise clockwise/counterclockwise don't make sense. For example one vector is along $x$, one along $y$. Is the angle $90^\circ$ or $270^\circ$? Depends if your axis is $z$ or $-z$.
Let's assume that you define the angle using the scalar and vector products, and none of the two vectors is null. Then $$\sin\theta=\frac{(\vec v_1\times\vec v_2)\cdot\hat d}{|\vec v_1||\vec v_2|}\\\cos\theta=\frac{\vec v_1\cdot\vec v_2}{|\vec v_1||\vec v_2|}$$ Here $\hat d$ is a unit vector in a direction perpendicular to the plane $(\vec v_1,\vec v_2)$. The choice of $\hat d$ will impact the value of the angle (the quadrant in which it lies). You can then use the $\mathrm{atan2}$ function to give an angle between $-\pi$ and $\pi$. If you really want, you can change that to go from $0$ to $2\pi$