Hallo Melody,
my english is not so good, but i start.
We have a Point P, the coordinate is ( x,y ). So we have P(x,y).
The question is, what is the angle from the x-axis to that Point (we call the angle also polar angle ). See: https://en.wikipedia.org/wiki/Polar_coordinate_system
The formula for the angular coordinate is : $$\alpha = \arctan{( \frac{y_p}{x_p} )}\\
\text{ or } \alpha = \mathrm{atan( \frac{y_p}{x_p} ) }$$
But this formula does not calculate the angle correctly. We have the same angle in the Quadrant ( I and III ) and in the Quadrant ( II and IV ).
Why?
Because $$\frac {+y_p}{+x_p} = \frac{-y_p}{-x_p} = +\frac {y_p}{x_p}$$ and $$\frac {+y_p}{-x_p} = \frac{-y_p}{x_p} = - \frac {y_p}{x_p}$$
If we divide y by x, the information about the quadrant has disappeared.
But we can see:
$$\\\small{\text{Point in the I. Quadrant $y_p > 0 $ and $ x_p > 0 $}}\\
\small{\text{Point in the II. Quadrant $y_p > 0 $ and $ x_p < 0 $}}\\
\small{\text{Point in the III. Quadrant $y_p < 0 $ and $ x_p < 0 $}}\\
\small{\text{Point in the IV. Quadrant $y_p < 0 $ and $ x_p > 0 $}}\\$$
We must correct the angular coordinate afterwards.
and if y or x is zero, we must put constants:
$$\\\small{\text{$ y_p = 0 $ and $ x_p > 0 \qquad \alpha = 0 $ }}\\
\small{\text{$ y_p > 0 $ and $ x_p = 0 \qquad \alpha = \frac{\pi}{2}$ }}\\
\small{\text{$ y_p = 0 $ and $ x_p < 0 \qquad \alpha = \pi$ }}\\
\small{\text{$ y_p < 0 $ and $ x_p = 0 \qquad \alpha = \frac{3}{2}\pi$ }}\\$$
We have succeed, there is a function which takes this work from us!
The funktion is atan2
and needs two parametres $$\small{\text{ $y_p$ and $x_p$}}$$
The new formula for the angular coordinate is : $$\boxed{\ \alpha = \mathrm{atan} 2{( y_p, x_p )}\ }$$
You can also use atan2, see examples below, to get the angle in the quadrant (I, II, III, and IV):
$$\\\text{Formula:}\\
\alpha = \mathrm{atan2}\ {(\Delta y, \Delta x)}$$
Examples:
http://web2.0rechner.de/#atan2(1,1) $$\alpha = 45\ \mathrm{degrees} \qquad \text{Quadrant I}$$
http://web2.0rechner.de/#atan2(1,-1) $$\alpha = 135\ \mathrm{degrees} \qquad \text{Quadrant II}$$
http://web2.0calc.com/#atan2(-1,-1) $$\alpha = -135\ \mathrm{degrees} \qquad \text{Quadrant III}$$
http://web2.0rechner.de/#atan2(-1,1) $$\alpha = -45\ \mathrm{degrees} \qquad \text{Quadrant IV}$$
Click the "=" Button in the link
Thanks Heureka,
I have never seen this before. I am going to try it too :))
I am trying to use acos(0.5) your way and get the different quadrant answers but it is not working for me.
Can you show me how to do this please Heureka ?
Hallo Melody,
my english is not so good, but i start.
We have a Point P, the coordinate is ( x,y ). So we have P(x,y).
The question is, what is the angle from the x-axis to that Point (we call the angle also polar angle ). See: https://en.wikipedia.org/wiki/Polar_coordinate_system
The formula for the angular coordinate is : $$\alpha = \arctan{( \frac{y_p}{x_p} )}\\
\text{ or } \alpha = \mathrm{atan( \frac{y_p}{x_p} ) }$$
But this formula does not calculate the angle correctly. We have the same angle in the Quadrant ( I and III ) and in the Quadrant ( II and IV ).
Why?
Because $$\frac {+y_p}{+x_p} = \frac{-y_p}{-x_p} = +\frac {y_p}{x_p}$$ and $$\frac {+y_p}{-x_p} = \frac{-y_p}{x_p} = - \frac {y_p}{x_p}$$
If we divide y by x, the information about the quadrant has disappeared.
But we can see:
$$\\\small{\text{Point in the I. Quadrant $y_p > 0 $ and $ x_p > 0 $}}\\
\small{\text{Point in the II. Quadrant $y_p > 0 $ and $ x_p < 0 $}}\\
\small{\text{Point in the III. Quadrant $y_p < 0 $ and $ x_p < 0 $}}\\
\small{\text{Point in the IV. Quadrant $y_p < 0 $ and $ x_p > 0 $}}\\$$
We must correct the angular coordinate afterwards.
and if y or x is zero, we must put constants:
$$\\\small{\text{$ y_p = 0 $ and $ x_p > 0 \qquad \alpha = 0 $ }}\\
\small{\text{$ y_p > 0 $ and $ x_p = 0 \qquad \alpha = \frac{\pi}{2}$ }}\\
\small{\text{$ y_p = 0 $ and $ x_p < 0 \qquad \alpha = \pi$ }}\\
\small{\text{$ y_p < 0 $ and $ x_p = 0 \qquad \alpha = \frac{3}{2}\pi$ }}\\$$
We have succeed, there is a function which takes this work from us!
The funktion is atan2
and needs two parametres $$\small{\text{ $y_p$ and $x_p$}}$$
The new formula for the angular coordinate is : $$\boxed{\ \alpha = \mathrm{atan} 2{( y_p, x_p )}\ }$$