# Find the angle that creating with Y axis in degrees

I want to find the Q angle that creating with Y axis in degrees using vectors

• Let me see if I understand the question. You have two points $(x_1, y_1)$ and $(x_2, y_2)$, and you want to know the angle between the $y$-axis and the line they determine. Is that right? (And there is some requirement to "use vectors" in some way?) – Jason Zimba Mar 16 '14 at 16:42
• yes that's what i want – JanithOCoder Mar 16 '14 at 17:09
• OK. I added vectorial aspect to my answer below. – Jason Zimba Mar 16 '14 at 17:17
• Note, perhaps based on your screen name, I was thinking about computer code here. I went with $\cos^{-1}$ rather than $\tan^{-1}$ so that you would never throw an error due to a vanishing denominator. – Jason Zimba Mar 16 '14 at 17:17

Let $Y_1 = {\rm max}(y_1, y_2)$ and $Y_2 = {\rm min}(y_1, y_2)$. Then the angle between the line and the $y$-axis is $$\cos^{-1}\!\left({Y_1 - Y_2\over\sqrt{(x_1-x_2)^2 +(Y_1-Y_2)^2} }\right)\,.$$
If there is some requirement to use vectors, then the above expression can be derived vectorially as follows. Letting ${\bf r}_1 = (x_1, Y_1)$ and ${\bf r}_2 = (x_2, Y_2)$, define the unit vector $\hat{\bf r} = ({\bf r}_1 - {\bf r}_2)/||{\bf r}_1-{\bf r}_2||$. The unit vector $\hat{\bf y}$ defining the direction of the $y$-axis is $\hat{\bf y} = (0, 1)$. Now using the dot product, $\cos\theta = \hat{\bf y}\cdot \hat{\bf r}$. Working with components leads to the explicit expression above.
I don't know how to do with vectors. A simple way is to use $$\tan(90-\theta)=\dfrac{y_2-y_1}{x_2-x_1}$$
$$\tan\theta=\dfrac{x_2-x_1}{y_2-y_1}$$
Take the solution of the above equation s.t. $\theta<\pi/2.$