4
$\begingroup$

I've been learning about the unit circle, sine, cosine, and the like in my introduction to trigonometry course, but I'm drawing a blank here.

If I have a circle centered at the origin, with radius r and point(x,y), how do I find the measure of the angle from (r,0) to (x,y)?

For example, if the radius is 1 and the point is ($-\frac{1}{\sqrt{2}}$,$\frac{1}{\sqrt{2}}$), the number I would want is 135 degrees, or the equivalent in radians.

edit: Actually, I would also appreciate a formula to calculate this measurement between any two points on a circle.

  • 2
    Use the inverse trigonometric functions. You know the $\sin$ of the angle in your example is $1/\sqrt2$ (the $y$-coordinate of the point). What angle in the second quadrant has that as its $\sin$? You should recognize that it's one of the "special angles". Formally, you could take $\arcsin(1/\sqrt2)$. But this would give you the angle in the first quadrant with the proper $\sin$. Then you'd find the equivalent angle in the second quadrant.2012-03-06
  • 0
    @DavidMitra, That was my train of thought: to use the inverse of the tangent function and other bits of logic to determine the angle based on quadrant, but I was hoping for a formula that was more direct.2012-03-06
  • 1
    Unfortunately, that's what you'd have to do. That's because the inverse trig functions are *functions*, they only return one value. But there are usually two distinct angles in $[0,2\pi)$ that have a given value of $\sin$ (or $\tan$, etc...).2012-03-06

1 Answers 1

4

There is a two variable function, called $\text{atan2}$ in C, that may do the job for you, if something like it is built into the piece of software that you are using.

For some discussion of the $\text{atan2}$ function, see this.

Roughly speaking, $\text{atan2}(y,x)$ is $\arctan(y/x)$ if $x$ is positive. If $x$ is negative, and $y\ge 0$, then $\text{atan2}(y,x)=\pi+\arctan(y/x)$, while if $x<0$ and $y<0$, then $\text{atan2}(y,x)=-\pi+\arctan(y/x)$. And so the program won't blow up, $\text{atan2}(y,x)$ is defined in the reasonable way when $x=0$.

In particular, $\text{atan2}(1/\sqrt{2},-1/\sqrt{2})=3\pi/4$, precisely what you wanted. You may be less happy with $\text{atan2}(-1/\sqrt{2},-1/\sqrt{2})$.

Warning: While many software packages implement an $\text{atan2}$-like function, the name and the syntax are not universal. Sometimes $x$ and $y$ are interchanged. The details for Fortran, C, Mathematica, MATLAB, and Excel, to mention some examples, are slightly different!